Organizing JavaScript Tools

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
PHK
User
Posts: 1684
Joined: Tue Nov 24, 2020 4:02 pm

Organizing JavaScript Tools

Post by PHK »

I have a confession: my portfolio of JS tools is a mess. Whilst all the files are in the correct Apps folder and some show in my desktop Add-on Tools tab, some do not and I don't know how to access them. I would prefer to have all my JS tools in my Add-on Tab although I may place duplicates in other tabs such as Comments, etc. for convenience.

So, (i) how do I get access to all my saved JS tools and (ii) how do I get all JS tools to show in my Add-on Tools tab?

All help and suggestions will be welcome.
All best,

FringePhil
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 13322
Joined: Wed Jan 03, 2018 6:52 pm

Re: Organizing JavaScript Tools

Post by Daniel - PDF-XChange »

Hello, PHK

You would need to modify this in each JS file itself.
Under the app.addtoolbutton function - there are a few properties, one or two indicating toolbar (if that line is omitted, they will default to the add-on tools toolbar) and one labelled nPos (which dictates the order on whichever toolbar they are part of). EG;
image.png
Modify these items to adjust the default positions of your custom tool buttons.

Kind regards,
You do not have the required permissions to view the files attached to this post.
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
[email protected]
User avatar
PHK
User
Posts: 1684
Joined: Tue Nov 24, 2020 4:02 pm

Re: Organizing JavaScript Tools

Post by PHK »

Thank you, Daniel. However, I am not inclined to go down the rabbit hole of learning how to write JS just to solve this minor annoyance.
All best,

FringePhil
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 13322
Joined: Wed Jan 03, 2018 6:52 pm

Re: Organizing JavaScript Tools

Post by Daniel - PDF-XChange »

Hello, PHK

In this case, it isn't so much a matter of learning to write JS, as it is - if these buttons are on the toolbar, they already have most of this in place. In most cases, you simply need to change the singular number following the nPos value, to sort these items.

In any situation, I will wish you an excellent day!

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
[email protected]
User avatar
Mathew
User
Posts: 957
Joined: Thu Jun 19, 2014 7:30 pm

Re: Organizing JavaScript Tools

Post by Mathew »

Daniel - PDF-XChange wrote: ↑Mon Sep 21, 2026 4:25 pm Modify these items to adjust the default positions of your custom tool buttons.
Of course, everything is more complicated due to the legacy of an old API: There are two commands that can add tool buttons in the Ribbon UI:
  • app.addToolButton adds buttons to the "Add-on" ribbon
  • app.addMenuItem adds to any other menu
Plus, javascript can also add sub-menus or whole new ribbons with app.addSubMenu...

Sooo, it becomes a bit of a haystack, but searching for the following in the text of a javascript file should give you a clue where the default locations were -- although the ID can be a bit cryptic:
  • cParent gives the location in the classic UI
  • cRbParent gives the location in the ribbon UI
But there's more: These commands only set the default location in PDF-XChange. PDF-XChange allows users to change the position of these items with the "Customize Toolbars…" by dragging them to different locations. (A wrinkle in this is that one could completely delete a button when customizing, and then it will just not show. I have no idea how to bring it back once that is done.)

I think one feature request that could make things easier for FringePhil (and for me) would be for there to be a category of javascripts in the "Customize Toolbars" "Commands" tab (all the custom tools have the prefix js.cmd. for their ID so internally PDF XChange does keep track of which menu items came from javascript)...

My Javascript Snippets tool is a start on a tool that one would install all scripts through, and would keep track of where all the scripts are; but it's still a very early work in progress.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 13322
Joined: Wed Jan 03, 2018 6:52 pm

Re: Organizing JavaScript Tools

Post by Daniel - PDF-XChange »

Hello, Mathew

A very good point - and thank you for the breakdown. I actually forgot we had added the option to manually drag custom tools around as well! I expect that you can only reset those by using the "reset toolbars" option in the customize toolbars window (or with a complete application settings reset)

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
[email protected]
User avatar
PHK
User
Posts: 1684
Joined: Tue Nov 24, 2020 4:02 pm

Re: Organizing JavaScript Tools

Post by PHK »

i have used and appreciate the ability to drag JS tools around and, more specifically, from the dedicated ribbon of Add-on Tools. And that's why I would like to collect all my JS tools in that one place as a starting point for customizing my UI with these tools.
All best,

FringePhil
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 13322
Joined: Wed Jan 03, 2018 6:52 pm

Organizing JavaScript Tools

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
[email protected]