Writing a script - to Copy and Paste object nearby  SOLVED

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

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
dwg11
User
Posts: 64
Joined: Fri Jan 06, 2017 5:27 am

Writing a script - to Copy and Paste object nearby

Post by dwg11 »

With the Copy and Paste function, the pasted object is directly above the original, this is a bit of a problem for me.
There was an option to Paste to the mouse location ... but I was running into issues when working on adjacent pages.

I was wondering if there was a away to write a script to Copy and Paste the object, at X mm to the right and Y mm above. Similar to the "Duplicate Annotations" function. And then an icon would need to be created as well.
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8544
Joined: Wed Jan 03, 2018 6:52 pm

Re: Writing a script - to Copy and Paste object nearby  SOLVED

Post by TrackerSupp-Daniel »

Hi, dwg11

I would need to double check with some of our dev team members on the scripting side to see if this would be possible, but I do believe that it should be with custom JavaScript. If you have the knowledge, This article should help you to create it:
https://www.pdf-xchange.com/knowle ... the-Editor

Beyond that, I should also note that the "copied" annotation will always be selected by default when pasting, so if you only need to make quick adjustments, you can also use the arrow keys after pasting to manually adjust the position. This might be more handy as it would give you more flexibility in the exact position the content is placed in.

Kind regards,
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
dwg11
User
Posts: 64
Joined: Fri Jan 06, 2017 5:27 am

Re: Writing a script - to Copy and Paste object nearby

Post by dwg11 »

Thanks for responding.
I've looked at the reference documentation but it's a bit too advanced for me.
Can you get me started as to how to add the button at least.

So far I've created a folder called "JavaScripts" in directory "C:\Users\USER\AppData\Roaming\Tracker Software\PDFXEditor\3.0".
I've created a file called "Custom.js" in the above folder and just pasted some code in the link mentioned ... this is probably WRONG.

I don't know how to tell the program how to talk with the javascript.
Are there instructions on how to add the button, to get started.
Willy Van Nuffel
User
Posts: 2387
Joined: Wed Jan 18, 2006 12:10 pm

Re: Writing a script - to Copy and Paste object nearby

Post by Willy Van Nuffel »

1) The additional (JavaScript) toolbar and button should normally appear somewhere on top at the left (in case of Classic toolbars) or in a specific tab/ribbon, called "Add-on Tools". I have added the "Zoom to 175%" example file Custom.js in a ZIP to this post. Maybe this can help ?

2) The problem with "paste" on the same position only seems to happen when you are using Copy/Paste from the menu (Classic toolbars). When you are using Copy/Paste from the shortcut-menu instead (right-click on the object), the copy is a few cm away from the original. Can you confirm this ?

3) What about using the following work-around: make the copy in the following way:
- click the object to select it
- position the mouse-pointer in the middle of the object (so that it becomes a pointer in the four directions)
- press and maintain the CTRL-key
- drag a copy to the desired position

Regards.
Attachments
Custom.zip
(257 Bytes) Downloaded 27 times
Edit - copy paste.png
Edit - copy paste.png (13.96 KiB) Viewed 1012 times
Rightclick - copy paste.png
Copy via CTRL drag and drop.png
dwg11
User
Posts: 64
Joined: Fri Jan 06, 2017 5:27 am

Re: Writing a script - to Copy and Paste object nearby

Post by dwg11 »

OK no worries.
A funny thing happened when I switched to Classic view ... the button came up and it worked.
The javascript code I had in the previous mentioned script is shown below.
Interestingly it doesn't show in the Ribbon view.

Code: Select all

function zoom175()
{
    this.zoom = 175;
}

app.addToolButton({
    cName: "Zoom 175%",
    cLabel: "175%",
    cExec: "zoom175()",
    cTooltext: "Zoom to 175%",
    cEnable: true,
    nPos: -1
});
Screenshot.png
Willy Van Nuffel
User
Posts: 2387
Joined: Wed Jan 18, 2006 12:10 pm

Re: Writing a script - to Copy and Paste object nearby

Post by Willy Van Nuffel »

Don't you see this as an additional ribbon, in the Ribbon UI ?

¨Please a comprehensible answer to my points 2 and 3 ?
Attachments
Ribbon - Add-on Tools.png
dwg11
User
Posts: 64
Joined: Fri Jan 06, 2017 5:27 am

Re: Writing a script - to Copy and Paste object nearby

Post by dwg11 »

Yes, you're right, the Add-on tools was the second-last tab, I missed it.
That's good, at least something comes up.
I'll look at the required script next, please let me know what is available for the Copy and Paste actions. Or a link if you've seen something before.
Willy Van Nuffel
User
Posts: 2387
Joined: Wed Jan 18, 2006 12:10 pm

Re: Writing a script - to Copy and Paste object nearby

Post by Willy Van Nuffel »

Why invest more time into this ? - Please re-read my points 2 and 3.

Problem can be resolved by Tracker Software developers in a next release ?
Post Reply