[Tool] custom menu item to Mirror (Flip) annotations (markup)  SOLVED

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

User avatar
Mathew
User
Posts: 798
Joined: Thu Jun 19, 2014 7:30 pm

[Tool] custom menu item to Mirror (Flip) annotations (markup)  SOLVED

Post by Mathew »

I made a script to mirror selected annotations (markup) because PDF-XChange currently doesn't have that functionality. I've attached a zip file with it made into a menu item. It adds to the "Edit" menu before "Duplicate" on the classic UI, to the Selection sub-menu on the Home ribbon, and also adds a toolbar button to the Add-Ins toolbar. You can edit placement and add keyboard shortcuts through Customize Toolbars…
image(2).png
mirror annotations tool v2.5.zip

To install: unzip the file and put the three files into the Javascripts folder either in the application folder, or
C:\Users\[your user name]\AppData\Roaming\Tracker Software\PDFXEditor\3.0\Javascripts\
(If there's no Javascripts folder, make one)

When you restart PDFX-Change, it adds a menu item to Home > Selection (for the ribbon UI), or to the Edit menu (for the classic UI), and adds a button to the Add-on Tools:
image.png

If you don't want to install it, the script also works if you copy and paste the source code in the file 'mirror annotations tool.js' into the JavaScript console and run it from there.

Use
Select the annotations you want to mirror, and then the tool. It will open a dialog box where you can pick the mirroring options:
image(1).png

Abilities:
  • Mirrors Lines, Polylines, Polygons, Squares, Rectangles, Circles, and Pencil annotations
  • Repositions & rotates Text, Callouts, Stamps, Dimensions so that they match the rest of the mirrored markup
  • Can select which axis of the selected annotations to mirror about, and whether mirroring horizontally and/or vertically
  • Can mirror a copy of the annotations instead of mirroring the selected annotations; however, I prefer to copy and paste first, and then mirror that because then the mirrored annotations are selected already if you need to move them to the correct location.
Limitations: This is not an exhaustive list, just what I've run into while using it.
  • Cannot mirror stamps, pictures or other items that are an object that you can't edit in PDFX-Change. If you absolutely must mirror these items, you generally can by first flattening them, and then you can mirror them with the edit tool and the right click menu.
  • Doesn't mirror form elements.
  • It's not possible to change the selection within a javascript, so I can't make it select the new annotations if doing a mirror copy.
  • Adds a long list of items to the undo, (one for each item flipped) so it takes quite a few "undo"s to undo the flip.
  • Does not mirror text, but it re-positions it and changes the left/right alignment for horizontal mirrors. Fixed as of build 370: It currently can't get the left or right alignment of the text correct (bug fix promised in version 10 of pdfx-change viewtopic.php?p=166841#p166841 )
  • Fixed as of build 391 (maybe earlier) Bullet or numbered lists disappear when mirrored (they become just indented rows of text). I suspect this property is not available to javascript.
  • Fixed as of build 367 Pencil tool annotations get completely messed up because of a bug in PDFX-Change.
  • Fixed as of build 370: If the view is rotated, "horizontal" and "vertical" in the dialog won't be correct - as of build 370 viewState.pageViewRotation gives view rotation so this is fixed.
  • Add a comment if you see something else, I'll try to fix it.
You do not have the required permissions to view the files attached to this post.
Last edited by Mathew on Thu Feb 27, 2025 1:06 am, edited 22 times in total.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12660
Joined: Wed Jan 03, 2018 6:52 pm

Re: javascript: custom menu item to Mirror (Flip) annotations

Post by Daniel - PDF-XChange »

Hello, Mathew

Thank you for creating this, I am sure that it will help some users who have been eagerly awaiting this function. I do have one note though, here:
Mathew wrote: Fri Feb 10, 2023 5:45 pm Does not mirror text, but it repositions it. Because of a bug in PDFX-Change it currently can't get the left or right alignment of the text right either
You mention a bug in our software, but I do not believe this is a bug, moreso, a limitation in how comment "containers" and the "text" contained within them are separate items. You cannot modify the text content of a comment while only the container is selected, and so trying to do this goes outside the scope of what can be achieved with JS alone.

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
User avatar
Mathew
User
Posts: 798
Joined: Thu Jun 19, 2014 7:30 pm

Re: javascript: custom menu item to Mirror (Flip) annotations

Post by Mathew »

Hi Daniel,
I didn't have time to post crosslinks to the forum items. The text alignment issue is mentioned in this post, with a way to reproduce it:
viewtopic.php?p=166808#p166808
- Mathew.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12660
Joined: Wed Jan 03, 2018 6:52 pm

Re: javascript: custom menu item to Mirror (Flip) annotations

Post by Daniel - PDF-XChange »

Hello, Mathew

I see, thank you for clarifying and providing that.

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
User avatar
Mathew
User
Posts: 798
Joined: Thu Jun 19, 2014 7:30 pm

Re: javascript: custom menu item to Mirror (Flip) annotations

Post by Mathew »

With build 367.0 this tool also works for Ink annotations.

I've made a slightly more snazzy version below that adds a button to the Add-in toolbar. As before, copy the script and save as a text file with .js suffix to this folder:
C:\Users\[your user name]\AppData\Roaming\Tracker Software\PDFXEditor\3.0\Javascripts\mirror annotations tool.js

or you can run it from the javascript window but the toolbar button will go away next time you run PDFxchange.

Code: Select all

// script minified using http://jscompress.com/ also need to escape all backslashes
// tool data and custom icon
var iconSet_mirrorTool = { mirror:
"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFC0C0C00000000000000000FF91C8F6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFC9C9C9FFB5B5B50000000000000000FF7BBFF6FFA1D0F50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFB6B6B6FFB5B5B50000000000000000FF7BBFF7FF7DBFF60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFB1B1B1FFB5B5B50000000000000000FF7BBFF7FF70BBF7FFBAD8F5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFB4B4B4FFB1B1B1FFB5B5B50000000000000000FF7BBFF6FF71BBF7FF77BDF70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFBBBBBBFFB1B1B1FFB1B1B1FFB5B5B50000000000000000FF7BBFF7FF71BBF7FF71BBF7FF87C4F600000000000000000000000000000000000000000000000000000000000000000000000000000000FFAFAFAFFFB1B1B1FFB1B1B1FFB5B5B50000000000000000FF7BBFF7FF71BBF7FF71BBF7FF6FB9F6000000000000000000000000000000000000000000000000000000000000000000000000FFB6B6B6FF989898FFAAAAAAFFB1B1B1FFB6B6B60000000000000000FF7BBFF7FF71BBF7FF63B4F6FF42A5F5FF84BFF50000000000000000000000000000000000000000000000000000000000000000FF999999FF989898FF999999FFAAAAAAFFB6B6B60000000000000000FF7BBFF7FF63B4F6FF45A6F5FF42A5F5FF43A5F500000000000000000000000000000000000000000000000000000000FF9B9B9BFF989898FF989898FF989898FF999999FFAEAEAE0000000000000000FF6FB8F6FF43A6F5FF42A5F5FF42A5F5FF42A5F5FF7AB7F50000000000000000000000000000000000000000FFCCCCCCFF9A9A9AFF989898FF989898FF989898FF989898FFA2A2A20000000000000000FF58ADF5FF42A5F5FF42A5F5FF42A5F5FF42A5F5FF45A6F5FFAED2F500000000000000000000000000000000FFA2A2A2FF989898FF989898FF989898FF989898FF989898FFA1A1A10000000000000000FF57ADF5FF42A5F5FF42A5F5FF42A5F5FF42A5F5FF42A5F5FF58AEF4000000000000000000000000FFB2B2B2FF989898FF989898FF989898FF989898FF989898FF989898FFA1A1A10000000000000000FF56ACF5FF42A5F5FF42A5F5FF42A5F5FF42A5F5FF42A5F5FF42A5F5FF7CBCF50000000000000000FFA4A4A4FF989898FF989898FF989898FF989898FF989898FF989898FFA1A1A10000000000000000FF56ADF5FF41A5F5FF41A5F5FF41A5F5FF41A5F5FF41A5F5FF41A5F5FF5FAFF500000000FFCBCBCBFFAFAFAFFFAFAFAFFFAFAFAFFFB0B0B0FFAFAFAFFFAFAFAFFFB0B0B0FFB5B5B50000000000000000FF7EBEF5FF71B9F5FF71B9F5FF71B9F4FF71B9F5FF70B9F5FF71B9F5FF71B9F6FFA7D0F500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
script: 'var flipDir,flipAxis,flipCopy;(function(a){var b={selAnnots:[],initialize:function(b){if(b&&0<b.length){this.selAnnots=b,null==flipDir&&(flipDir={horiz:!0,vert:!1});var c=a.getPageRotation({nPage:this.selAnnots[0].page});for(a.viewState.pageViewRotation&&(c+=a.viewState.pageViewRotation),0>c&&(c=360-c);360<=c;)c-=360;return this.flipDialog.pageRotation=c,app.execDialog(this.flipDialog)}return"No Annotations selected."},doFlip:function(){var a=this.getBounds(this.selAnnots),b=this.getAxisPt(a,flipAxis);this.flipAnns(b,this.selAnnots)},getAxisPt:function(a,c){var d=[a.slice(0,2),a.slice(2,4)],b={AxTL:[[0,0],[1,1]],AxTC:[[0,1],[1,1]],AxTR:[[1,1],[1,1]],AxML:[[0,0],[0,1]],AxMC:[[0,1],[0,1]],AxMR:[[1,1],[0,1]],AxBL:[[0,0],[0,0]],AxBC:[[0,1],[0,0]],AxBR:[[1,1],[0,0]]}[c],e=[(+d[b[0][0]][0]+d[b[0][1]][0])/2,(+d[b[1][0]][1]+d[b[1][1]][1])/2];return e},rotatePoint:function(a,b,c){var d=c*Math.PI/180,e=a[0],f=a[1],g=b[0],h=b[1],i=(e-g)*Math.cos(d)-(f-h)*Math.sin(d)+g,j=(e-g)*Math.sin(d)+(f-h)*Math.cos(d)+h;return[i,j]},rotateRect:function(a,b,c){if(b){void 0===c&&(c=[(a[0]+a[2])/2,(a[1]+a[3])/2]);var d=[];for(let e=0;e<a.length-1;e+=2)d=d.concat(this.rotatePoint([a[e],a[e+1]],c,b));return d}return a},toFlatArray:function(b){var a,c=[];for(let d in b)a=b[d],"object"==typeof a[0]&&(a=this.toFlatArray(a)),c=c.concat(a);return c},getBounds:function(a){var b=[],c=[],d=[];for(let e in a){switch(c=a[e].rect,d=this.getAxisPt(c,"AxMC"),a[e].type){case"PolyLine":case"Polygon":c=this.toFlatArray(a[e].vertices);break;case"Ink":c=this.toFlatArray(a[e].gestures);break;default:a[e].callout&&0<a[e].callout.length&&(c=c.concat(a[e].callout));}c=this.rotateRect(c,a[e].rotation,d);for(let a=0;a<c.length-1;a+=2)("undefined"==typeof b[0]||c[a]<b[0])&&(b[0]=c[a]),("undefined"==typeof b[2]||c[a]>b[2])&&(b[2]=c[a]),("undefined"==typeof b[1]||c[a+1]<b[1])&&(b[1]=c[a+1]),("undefined"==typeof b[3]||c[a+1]>b[3])&&(b[3]=c[a+1])}return b},flipLine:function(a,b){for(let c=0;c<b.length;c++)b[c]=this.moveLineArray(a,b[c]);return b},moveLineArray(a,b){for(let c=0;c<b.length;c+=2)flipDir.horiz&&(b[c]=2*a[0]-b[c]),flipDir.vert&&(b[c+1]=2*a[1]-b[c+1]);return b},doRotation:function(a){return flipDir.horiz&&(a=-a),flipDir.vert&&(a=-a),a},flipTextAlign:function(a){var b=a.alignment;return flipDir.horiz&&1!=b&&(b=2-b),b},flipAnns:function(b,c){var d=[],e={};for(let g in c)switch(flipCopy?(e=c[g].getProps(),!e.richContents.length&&delete e.richContents,e=a.addAnnot(e)):e=c[g],e.type){case"Line":d=this.flipLine(b,e.points),e.leaderLength&&flipDir.vert&&(e.leaderLength=-e.leaderLength),"LineDimension"==e.intent&&flipDir.horiz&&(d=d.slice(1,2).concat(d.slice(0,1))),e.points=d;break;case"PolyLine":case"Polygon":e.setProps({vertices:this.flipLine(b,e.vertices),rotation:this.doRotation(e.rotation)});break;case"FreeText":e.callout&&0<e.callout.length&&(e.callout=this.moveLineArray(b,e.callout)),e.alignment=this.flipTextAlign(e);case"Circle":case"Stamp":case"Text":case"Square":case"Squiggly":e.setProps({rect:this.moveLineArray(b,e.rect),rotation:this.doRotation(e.rotation)});break;case"Ink":for(var f in d=e.gestures,d)d[f]=this.flipLine(b,d[f]);e.setProps({gestures:d,rotation:this.doRotation(e.rotation)});}},flipDialog:{pageRotation:0,getUp:function(a,b){var c={v:a,h:b};switch(this.pageRotation){case 90:case 270:c={v:b,h:a};}return c},getAxDir:function(a,b){var c=["AxTL","AxTC","AxTR","AxMR","AxBR","AxBC","AxBL","AxML"],d=c.indexOf(a);if(-1<d){switch(this.pageRotation){case 90:d+=2*(b?-1:1);break;case 180:d+=4*(b?-1:1);break;case 270:d+=6*(b?-1:1);}return d+=7<d?-8:0,d+=0>d?8:0,c[d]}return"AxMC"},initialize:function(a){var b=this.getUp(flipDir.vert,flipDir.horiz),c={vDir:b.v,hDir:b.h,copy:flipCopy};c[this.getAxDir(flipAxis,!1)]=!0,a.load(c)},commit:function(a){var b=a.store(),c=this.getUp(b.vDir,b.hDir);flipDir.vert=c.v,flipDir.horiz=c.h;var d=["AxTL","AxTC","AxTR","AxML","AxMC","AxMR","AxBL","AxBC","AxBR"];for(let c in d)b[d[c]]&&(flipAxis=this.getAxDir(d[c],!0));flipCopy=b.copy},description:{name:"Mirror Annotations",align_children:"align_left",width:350,elements:[{type:"cluster",name:"Mirror Direction",align_children:"align_left",elements:[{type:"check_box",name:"Mirror Horizontally",item_id:"hDir"},{type:"check_box",name:"Mirror Vertically",item_id:"vDir"}]},{type:"cluster",name:"Mirror Location",align_children:"align_left",elements:[{type:"view",align_children:"align_row",elements:[{type:"radio",groupid:"Axes",item_id:"AxTL"},{type:"radio",groupid:"Axes",item_id:"AxTC"},{type:"radio",groupid:"Axes",item_id:"AxTR"}]},{type:"view",align_children:"align_row",elements:[{type:"radio",groupid:"Axes",item_id:"AxML"},{type:"radio",groupid:"Axes",item_id:"AxMC"},{type:"radio",groupid:"Axes",item_id:"AxMR"}]},{type:"view",align_children:"align_row",elements:[{type:"radio",groupid:"Axes",item_id:"AxBL"},{type:"radio",groupid:"Axes",item_id:"AxBC"},{type:"radio",groupid:"Axes",item_id:"AxBR"}]}]},{type:"check_box",name:"Copy and Mirror Selection",item_id:"copy"},{alignment:"align_right",type:"ok_cancel",ok_name:"Ok",cancel_name:"Cancel"}]}}},c=b.initialize(a.selectedAnnots);return"ok"==c&&b.doFlip(),c})(this);',
iconStream:function(val){var data=this[val];
	return {count:0, width:20, height:20, read:function(nBytes){return data.slice(this.count,this.count+=2*nBytes)}}}
};
// This adds a button to the Add-on Tools toolbar
app.addToolButton( {
	cName: "mirrorAnnotationsTool",
	cLabel: "Mirror",
	oIcon: iconSet_mirrorTool.iconStream("mirror"),
	cTooltext: "Flip/Mirror Comments…",
	cEnable: "event.rc = (this.selectedAnnots && this.selectedAnnots.length)",
	cExec: iconSet_mirrorTool.script }
);
// This adds a menu item to the edit menu
app.addMenuItem( {
	cName: "mirrorAnnotations",
	cUser: "Flip/Mirror Comments…",
	oIcon: iconSet_mirrorTool.iconStream("mirror"),
	cParent: "Edit",
	nPos: 13,
	cEnable: "event.rc = (this.selectedAnnots && this.selectedAnnots.length)",
	cExec: iconSet_mirrorTool.script }
);
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12660
Joined: Wed Jan 03, 2018 6:52 pm

javascript: custom menu item to Mirror (Flip) annotations

Post by Daniel - PDF-XChange »

:)
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
User avatar
Mathew
User
Posts: 798
Joined: Thu Jun 19, 2014 7:30 pm

Re: javascript: custom menu item to Mirror (Flip) annotations

Post by Mathew »

I made a few updates to the script and attached it below. I'll also update the one in the first post.
mirror annotations tool v2.1.zip
  • cleaned up code a bit
  • reduce number of undos that show up when the script mirrors annotations
  • annotation name is auto-generated when mirror and copy is used
  • add option to not try keeping dimension text upright - sometimes I want to flip the direction of the text on distance tool measurements because it's facing the wrong way
You do not have the required permissions to view the files attached to this post.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12660
Joined: Wed Jan 03, 2018 6:52 pm

Re: javascript: custom menu item to Mirror (Flip) annotations

Post by Daniel - PDF-XChange »

Hello, Mathew

Thank you once again for the fantastic update!

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
User avatar
Mathew
User
Posts: 798
Joined: Thu Jun 19, 2014 7:30 pm

Re: javascript: custom menu item to Mirror (Flip) annotations

Post by Mathew »

One more update on this.
mirror annotations tool v2.2.zip
  • Mirror the alignment of rich text when it flips horizontally
  • fix access to global variable so settings save between sessions
  • use corner points instead of bounds on rectangles so that rotated rectangle edges are correct
Limitation:
  • Bullet or numbered lists disappear when mirrored (they become just indented rows of text). I suspect this property is not available to javascript.
You do not have the required permissions to view the files attached to this post.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19930
Joined: Mon Jan 12, 2009 8:07 am

Re: javascript: custom menu item to Mirror (Flip) annotations

Post by Stefan - PDF-XChange »

Hello Mathew,

Once again, many thanks for the update!

Kind regards,
Stefan
User avatar
Mathew
User
Posts: 798
Joined: Thu Jun 19, 2014 7:30 pm

Re: javascript: custom menu item to Mirror (Flip) annotations

Post by Mathew »

Just a few small changes here - mostly to change how text is handled when mirrored:
  • add .rotate to properties duplicated so that duplicated text doesn't get automatically rotated to view
  • try to improve how text is mirrored - vertically mirrored text stays upright
mirror annotations tool v2.3.zip
You do not have the required permissions to view the files attached to this post.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12660
Joined: Wed Jan 03, 2018 6:52 pm

javascript: custom menu item to Mirror (Flip) annotations

Post by Daniel - PDF-XChange »

:)
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
User avatar
David.P
User
Posts: 1694
Joined: Thu Feb 28, 2008 8:16 pm

Re: javascript: custom menu item to Mirror (Flip) annotations

Post by David.P »

I'm just now getting around to mentioning (having just installed the Mirror Comments JavaScript) what a fantastic tool this is, even with its own gorgeous GUI.

The underlying JavaScript code is a piece of art!

I even managed to move the button to launch the Mirror Comments tool from the menu to the titlebar. Unfortunately, it doesn't stay there after restarting PDF-XChange Editor.

image.png

Since I'd like to use JavaScript to implement and use this and other custom features in PDF-XChange Editor more often in the future: is it possible to assign a keyboard shortcut to a JavaScript button, or generally to a JavaScript in the folder C:\Users\[Username]\AppData\Roaming\Tracker Software\PDFXEditor\3.0\JavaScripts, in order to call this particular button, or JavaScript?

In this context, what would be the best way to execute a sequence of several (menu) commands in succession via JavaScript, should this be possible?

Thanks very much
Best regards
David
You do not have the required permissions to view the files attached to this post.
Last edited by David.P on Mon Jan 22, 2024 7:48 pm, edited 1 time in total.
David.P
PDF-XChange Pro
User avatar
Paul - PDF-XChange
Site Admin
Posts: 7447
Joined: Wed Mar 25, 2009 10:37 pm

Re: javascript: custom menu item to Mirror (Flip) annotations

Post by Paul - PDF-XChange »

Hi, David.P

there is no option to specify a ribbon on which to put the Tool. If you are using the Classic menu yo can then tell it what menu it should be on:
5th8pk8C1NZgk9Av.png

Code: Select all

// This adds a menu item
    app.addMenuItem( {
        cName: "changeColorAllMenu",
        cUser: "Change Colors…",
        oIcon: iconSet_colorsTool.iconStream("button"),
        //cParent: "Tools", // Change this to "Comments" to put in the Comment menu, etc
        cParent: "Comments", // Change this to "Tools" to put in the Tools menu, etc
        //nPos: 13,
        cEnable: "event.rc = (this.selectedAnnots && this.selectedAnnots.length)",
        cExec: "changeColorsAll(this)" }
    );
cParent is what you want to use. 

Adding them to Toolbars (not menus) is not supported by the API.

Because Menu Items CAN be modified, it is possible to drag a menu item to a Toolbar but it will bot be retained as you observed, it will not survive an application restart. I am afraid that is due to the ISO specifications and will not change.

I am waiting to hear back about the Keyboard Shortcut - but I do not believe it possible. We will see...

Kind regards,
Paul - Tracker Supp
You do not have the required permissions to view the files attached to this post.
Best regards

Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
User avatar
Mathew
User
Posts: 798
Joined: Thu Jun 19, 2014 7:30 pm

Re: javascript: custom menu item to Mirror (Flip) annotations

Post by Mathew »

That's one reason I've stuck with the Classic UI.

I did put in a feature request to try to get Tracker devs to add some way to add buttons on the ribbon UI... viewtopic.php?t=40887

For now, I'm relegated to adding buttons in the "Add-On" toolbar (it's floating on the left in @David's screenshot). I think PDF XChange may accept bigger icons than the tiny 20x20 icons I've been using, but I've not tried it.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12660
Joined: Wed Jan 03, 2018 6:52 pm

javascript: custom menu item to Mirror (Flip) annotations

Post by Daniel - PDF-XChange »

:)
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
User avatar
Mathew
User
Posts: 798
Joined: Thu Jun 19, 2014 7:30 pm

Re: [Tool] custom menu item to Mirror (Flip) annotations

Post by Mathew »

Minor changes to the tool, mainly to get it to show up in the ribbon UI at Home > Selection. Updated in the post at the top also.
mirror annotations tool v2.4.zip

Changes:
  • add to ribbon UI,
  • 40x40 icon (copy of built-in mirror icon),
  • make strings translateable with 1ang.js
  • code changes to make dialog settings into private variables
These are the translation strings:

Code: Select all

# Translation file (requires 1ang v1.0 or later)
# filename must be "translationData.<domain>.json" and saved in the javascripts folder
# It is not necessary for all strings to be included in every language,
#   but don't put an empty string "" for the translation, because that's what will be shown!
# This must be formatted as a JSON file except that:
#   lines starting with # and empty lines are stripped out before processing

# "Language" is three letter code as output from app.language
# "Original Text" is case sensitive!
#   Notice that the last item in a list does not allow a comma after it.
# Format:
#  "Language 1": {
#    "Original Text": "Translated Text in Language 1",
#    "Original Text 2": ["Translated Text 2 singular", "Translated Text 2 plural"]
#   },
#  "Language 2": {
#    "Original Text": "Translated Text in Language 2"
#   }

{
 "": {
     "Mirror": "",
     "Flip/Mirror Comments…": "",
     "Error accessing global variable '%1'. Try:\n either uncheck 'Enable global object security policy',\n or (preferably) edit the file 'GlobData': Delete the line that begins with /D after the line \n/%1 <<": "",
     "Mirror Annotations": "",
     "Mirror Direction": "",
     "Mirror Horizontally": "",
     "Mirror Vertically": "",
     "Mirror Location": "",
     "Copy and Mirror Selection": "",
     "Mirror right/left alignment of text": "",
     "Maintain dimension text direction": "",
     "No Annotations selected.": ""
 }
}
You do not have the required permissions to view the files attached to this post.
User avatar
Paul - PDF-XChange
Site Admin
Posts: 7447
Joined: Wed Mar 25, 2009 10:37 pm

[Tool] custom menu item to Mirror (Flip) annotations

Post by Paul - PDF-XChange »

:)
Best regards

Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
User avatar
Mathew
User
Posts: 798
Joined: Thu Jun 19, 2014 7:30 pm

Re: [Tool] custom menu item to Mirror (Flip) annotations

Post by Mathew »

Minor change to deal with the .inReplyTo bug that showed up if using "Copy and Mirror selection".
mirror annotations tool v2.5.zip
You do not have the required permissions to view the files attached to this post.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19930
Joined: Mon Jan 12, 2009 8:07 am

Re: [Tool] custom menu item to Mirror (Flip) annotations (markup)

Post by Stefan - PDF-XChange »

Hello Mathew,

Thanks for that update!

Kind regards,
Stefan