How to make tool buttons work for all files when switching tabs between files that contain document-level JavaScript?

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
rakunavi
User
Posts: 1693
Joined: Sat Sep 11, 2021 5:04 am

How to make tool buttons work for all files when switching tabs between files that contain document-level JavaScript?

Post by rakunavi »

Hello all,

When multiple files containing the same Document Level JavaScript with tool buttons are opened and the tabs are switched to display each file, the tool buttons are enabled in only one of the files in the PDF-XChange Editor. In Acrobat, on the other hand, the tool buttons work on all files, even if multiple files are opened and tabs are switched.

  • figure.png
Is there any way to make the tool buttons available in all files when switching tabs in PDF-XChange Editor, provided that the scripts are not modified and document-level JavaScript is used?

See the video for more details.

  • Animation.gif

    SampleFiles.zip
The script used in the verification is the basic one introduced in the Knowledgebase page.

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
});
Thank you for taking the time to read this message.

Best regards,
rakunavi

- PDF-XChange Editor Plus Version: 10.2.1 build 385
- OS Version: Windows 11 Home 23H2 Build 22631.3007
- PC Model: Lenovo IdeaPad C340-15IWL, HP All-in-One 22-c0xx
You do not have the required permissions to view the files attached to this post.
TOP desires for PDFXCE
forum.pdf-xchange.com/viewtopic.php?t=39665 LassoTool
forum.pdf-xchange.com/viewtopic.php?t=38554 CmtGarbled
forum.pdf-xchange.com/viewtopic.php?t=37353 FulScrMultiMon
forum.pdf-xchange.com/viewtopic.php?t=41002 DisableTouchSelect
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11117
Joined: Wed Jan 03, 2018 6:52 pm

Re: How to make tool buttons work for all files when switching tabs between files that contain document-level JavaScript

Post by Daniel - PDF-XChange »

Hello, rakunavi

I would generally suggest that if you need to use the same script in multiple document, it would be better to simply create a *.js file, and place it into the Javascripts folder (as that article you linked details), so that it is loaded at the application level, instead of by opening a document.

I will pass this up to the Dev team to see if there is something we have done wrong here, just in case.

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
rakunavi
User
Posts: 1693
Joined: Sat Sep 11, 2021 5:04 am

Re: How to make tool buttons work for all files when switching tabs between files that contain document-level JavaScript

Post by rakunavi »

Hello Daniel, thank you for your reply.

As you pointed out, if the scripts are exactly the same, we can just put them in the JavaScript folder, but if they are based on the same script but only some parameters are changed according to the characteristics of the document, we have to rely on Document-Level JavaScript.

To use the above script as an example, this is a case where the cName and function name remain the same but only one zoom level value is changed. Of course, if the cName is unique for each document, the button will appear even in the PDF-XChange Editor. But then, as shown in the video below, the PDF-XChange Editor will also display the tool buttons of the inactive document, so if you have a lot of documents open, many tool buttons will overflow the screen.

  • Animation.gif
Ultimately, the issue seems to come down to the following two points

  • How to handle the case where the same cName is defined for toolbutton of Document-Level JavaScript in multiple documents?
    • Whether Document-Level JavaScript toolbuttons in inactive documents should be displayed or not?
    The handling of these points differs depending on the PDF software. For example, with Foxit Editor, if the same cName is defined for a toolbutton in Document-Level JavaScript in multiple documents, the behavior is the same as in Acrobat.

    I am not sure if the behavior in Acrobat is compliant with PDF standards, but personally I would like PDF-XChange Editor to work the same way as Acrobat.

    Please give my best regards to the developers.

    Best regards,
    rakunavi
    You do not have the required permissions to view the files attached to this post.
    TOP desires for PDFXCE
    forum.pdf-xchange.com/viewtopic.php?t=39665 LassoTool
    forum.pdf-xchange.com/viewtopic.php?t=38554 CmtGarbled
    forum.pdf-xchange.com/viewtopic.php?t=37353 FulScrMultiMon
    forum.pdf-xchange.com/viewtopic.php?t=41002 DisableTouchSelect
    User avatar
    Daniel - PDF-XChange
    Site Admin
    Posts: 11117
    Joined: Wed Jan 03, 2018 6:52 pm

    Re: How to make tool buttons work for all files when switching tabs between files that contain document-level JavaScript

    Post by Daniel - PDF-XChange »

    Hello, rakunavi

    For the moment, you will need to ensure that these actions have a different name per document, but the request has been made, hopefully we can see a similar handling to Adobe in the future.

    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