Reverse PDF page order

Please post any ideas or requests for new features here for the End User Version of PDF-XChange (printer Drivers)

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, John - Tracker Supp, Ivan - Tracker Software, Tracker Supp-Stefan, Tracker - Clarion Support, moderators, Support Staff

Post Reply
Karyudo
User
Posts: 13
Joined: Sun Oct 13, 2019 9:48 pm

Reverse PDF page order

Post by Karyudo »

I have some documents that I have found scan best when stacked in my scanner in such a way that the finished PDF is in reverse page order (e.g. 4, 3, 2, 1). I'd like to see a one-click / keyboard shortcut solution that would reverse the page order (e.g. 1, 2, 3, 4).

Or is this possible already, somehow?
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17889
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Reverse PDF page order

Post by Tracker Supp-Stefan »

Hello Karyudo,

Reversing the page order can be done with a quick JS, and this topic shows you how you can actually add a custom button so that you can have that as a one click action:
viewtopic.php?f=62&t=28407&p=111667

Regards,
Stefan
Karyudo
User
Posts: 13
Joined: Sun Oct 13, 2019 9:48 pm

Re: Reverse PDF page order

Post by Karyudo »

This is not enough information for me to get this working. I've made a C:\Program Files\PDF-XChange Editor\PDF Editor\JavaScripts directory, and have made a new ReversePageOrder.js file in that directory, but I don't know where I'm supposed to be looking for a new button, because it's not there.

This "help" is disappointing, because it doesn't help.
User avatar
Radi - Tracker Supp
Site Admin
Posts: 600
Joined: Tue Mar 03, 2015 12:46 pm

Re: Reverse PDF page order

Post by Radi - Tracker Supp »

Hello Karyudo,

Once you place the .JS file in the correct folder and restart the Editor, a new tab of your ribbon interface will appear - "Add-on Tools". All JavaScript tools will be located in this tab.

I've created a .JS file from the scrip in the other topic for you, please find it here:

ReversePagesOrder.zip
(522 Bytes) Downloaded 117 times

Just extract the file to C:\Program Files\Tracker Software\PDF Editor\JavaScripts, Restart the Editor and then look for the new tool in the "Add-on Tools" tab.

image.png

Regards,
Radi
Karyudo
User
Posts: 13
Joined: Sun Oct 13, 2019 9:48 pm

Re: Reverse PDF page order

Post by Karyudo »

I'm pretty sure I've done exactly this, and it doesn't work.

I've put JavaScripts folders in both locations discussed in these forums (C:\Users\<<redacted>>\AppData\Roaming\Tracker Software\PDFXEditor\3.0\JavaScripts and C:\Program Files\Tracker Software\PDF Editor\JavaScripts), and nothing.
JavaScripts folder with js files.png
ReversePageOrder js contents.png
PDF X-Change - Nada.png
I even uninstalled 7 from the non-standard folder I chose when I installed it, and re-installed 8.0 in the default location. Still nothing.

I don't know if it's related, but I've also found that when I try to switch the UI to Classic Toolbars, the Editor immediately disappears (window gone, nothing in Task Manager).

So now, after troubleshooting for a while, I've got *two* ways in which this doesn't work.

I hope it's some stupid error on my part, but I don't see it. Any further suggestions?
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8544
Joined: Wed Jan 03, 2018 6:52 pm

Re: Reverse PDF page order

Post by TrackerSupp-Daniel »

Hello Karyudo,

The *.js file contained within the zip folder should go directly inside the javascripts folders, not the zip folder itself, so it should look like this:
image.png
image.png (6.56 KiB) Viewed 5693 times
Beyond that, this crash you mention seems unrelated, but could be resolved with the same action. We have seen a few issues with the application caused by some windows updates, which have been resolved in the most recent windows update. these issues generally only affect printers, but as the trouble lies with how windows is managing certain file types, it could affect our UI and its JavaScript functions.

Could I ask you to verify that windows itself is fully up to date, then restart the PC and try this once more?

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
Karyudo
User
Posts: 13
Joined: Sun Oct 13, 2019 9:48 pm

Re: Reverse PDF page order

Post by Karyudo »

I think if you check the attached image from my previous post, you'll see that I've got the .js file in the directory properly.

That screenshot is from just one of the two places forum posts have said the JavaScripts folder should go, but I've got the same folder in both places.

I just updated Windows (it said "up to date," but I forced it to check, and a .NET update installed), and then rebooted: same ol' nothing for the Java; same ol' crash-and-disappear for UI-switching.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17889
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Reverse PDF page order

Post by Tracker Supp-Stefan »

Hello Karyudo,

I see you have two JS files in your folder, and if both have nPos: 0 in them - this could cause conflicts.
Can you please share your .js file for the reverse page order here - so that I can test it at my end?

Regards,
Stefan
Karyudo
User
Posts: 13
Joined: Sun Oct 13, 2019 9:48 pm

Re: Reverse PDF page order

Post by Karyudo »

I finally have some time to pick this up again—and it's just as frustrating as before.

I uninstalled PDF X-Change Editor completely, and then reinstalled, and then re-made the JavaScripts directory and put the .js in it, and then re-started Editor, and... nothing. Well, at least not any JavaScript. Somehow, all of my file history, etc., still existed, which seems wrong.

I tried the same thing on another computer with a fresh install of Windows 10, and that works.

So why doesn't the JavaScript extra menu show up on my main computer? That doesn't make any sense. Unless PDF X-Change Editor doesn't delete itself properly when uninstalling (like I suspect, given that the file history is still there when the software is re-installed).
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8544
Joined: Wed Jan 03, 2018 6:52 pm

Re: Reverse PDF page order

Post by TrackerSupp-Daniel »

Hi, Karyudo

When uninstalling we only remove files which are created by the Installation process, namely the application itself, and some temp files. All custom content, such as your Stamps and JavaScript files should be left in place, we also do not delete settings stored in the registry, as deleting these during uninstall would mean that every time you update the software your entire UI customization, History, license keys, etc would be removed.
If you do wish to perform a "clean reinstallation" you will want to first uninstall the software, then navigate to "C:\Program Files" and delete the "Tracker Software" folder, do the same under %appdata% , and finally delete the Tracker software registry keys located in both HKCU and HKLM here:
Computer\HKEY_CURRENT_USER\Software\Tracker Software
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Tracker Software
This should remove all traces of the application. Remember that if you are doing this, you should restart the PC before reinstalling as well to be sure the registry changes can properly take effect.

Following that, if the issue still persists, can you please send a screenshot of the Editor preferences (Ctrl+K), under JavaScript.

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
Karyudo
User
Posts: 13
Joined: Sun Oct 13, 2019 9:48 pm

Re: Reverse PDF page order

Post by Karyudo »

Success! I uninstalled, removed all of the breadcrumbs left in other locations as you'd specified, and then rebooted. Then reinstalled, made the JavaScripts folder and added the .js file (this is maybe the sixth or eighth time I've done that, so I'm getting pretty good at it...) before firing up Editor. Finally, for the first time on this machine, I got the "Add-on Tools" button on the ribbon.

I even got somewhat cleverer than I am usually, and copied back the %appdata% data that I saved a copy of. Which also restored my file history and presumably a few other things. After doing that, I restarted Editor and confirmed the ReverseSortOrder .js still works. It does. Yay, me.

So the six-month effort to get this working is finally over! (Maybe you could hear my shout of triumph across Georgia Strait?)
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8544
Joined: Wed Jan 03, 2018 6:52 pm

Re: Reverse PDF page order

Post by TrackerSupp-Daniel »

Hi, Karyudo

Glad to hear it worked! (And I was wondering what the ringing in my ears was :lol: )

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
simple
User
Posts: 9
Joined: Thu Jan 30, 2020 8:13 pm

Re: Reverse PDF page order

Post by simple »

Good feature to add to the app
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8544
Joined: Wed Jan 03, 2018 6:52 pm

Re: Reverse PDF page order

Post by TrackerSupp-Daniel »

Hi, simple

I am afraid that it is unlikely we will be adding this feature to the application, it is something well handled by JavaScript, and there are already resources available to add buttons to run JavaScript to your UI directly. Please see Radi's post here: viewtopic.php?f=7&t=33303#p137305

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
natural_wanders
User
Posts: 1
Joined: Thu Aug 20, 2015 2:38 am
Location: Sydney, Australia

Re: Reverse PDF page order

Post by natural_wanders »

This is pretty easy to do in PDF-XChange by exporting to images in reverse order and then creating a new document from these.

1. File > Export > Export To Images (and check the box for Reverse Order).
Use a clean directory so the images are all together.
Set the appropriate resolution for image quality if the default 150 dpi is insufficient.
2. File > New Document > From Image Files > Add Folder
The result will not be OCR'd so if you need that then just do :
3. Document > OCR Pages

Done ! Very quick and simple.
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8544
Joined: Wed Jan 03, 2018 6:52 pm

Re: Reverse PDF page order

Post by TrackerSupp-Daniel »

Hi, natural_wanders

That is an excellent alternative if you do not mind converting your document to images.

The JavaScript provided in Radi's post I linked to is also quick and easy to setup, and once done, you simply click a button in the UI to reverse pages. The JavaScript method has the advantage of leaving all page content exactly as it is though, no need to convert it to an image, or OCR it again afterwards, no loss of image quality, or flattening of comments either.

I would still recommend using the JavaScript for these reasons personally.

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
User avatar
David.P
User
Posts: 1521
Joined: Thu Feb 28, 2008 8:16 pm

Re: Reverse PDF page order

Post by David.P »

Hello Radi and @all,
Radi - Tracker Supp wrote: Fri Oct 18, 2019 6:01 am Once you place the .JS file in the correct folder and restart the Editor, a new tab of your ribbon interface will appear - "Add-on Tools". All JavaScript tools will be located in this tab.

[...]

Just extract the file to C:\Program Files\Tracker Software\PDF Editor\JavaScripts, Restart the Editor and then look for the new tool in the "Add-on Tools" tab.
Thank you very much for this information.

Are JavaScript tools that are added in this way also accessible in the classic interface? Or is it possible to move such JavaScript buttons to arbitrary places in the user interface by customization?

Best regards
David
David.P
PDF-XChange Pro
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8544
Joined: Wed Jan 03, 2018 6:52 pm

Re: Reverse PDF page order

Post by TrackerSupp-Daniel »

Hello, David.P

When a JS button is added in this way, it will appear by default in an "addon tools" tab in the ribbon UI:
image(1).png
and within a new toolbar just below the properties toolbar in the Classic UI:
image.png
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
User avatar
David.P
User
Posts: 1521
Joined: Thu Feb 28, 2008 8:16 pm

Re: Reverse PDF page order

Post by David.P »

Thank you Daniel, now I see the button also in the classic UI!
Best regards
David
:)
David.P
PDF-XChange Pro
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8544
Joined: Wed Jan 03, 2018 6:52 pm

Reverse PDF page order

Post by TrackerSupp-Daniel »

:)
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
User avatar
David.P
User
Posts: 1521
Joined: Thu Feb 28, 2008 8:16 pm

Re: Reverse PDF page order

Post by David.P »

Hello all,

a quick further question about the JavaScript buttons. Since I created some JavaScript buttons, the toolbar with the JavaScript buttons appears every time I start PDF-XChange Editor.

However, this is undesirable since I only rarely need the JavaScript buttons.

Is it possible to hide the JavaScript buttons toolbar permanently (and unhide it only manually if desired), as it is possible with all other toolbars?

Best regards
David

--
Addendum: after opening a second window of a PDF document in PDF-XChange Editor, the JavaScript button Toolbar cannot be closed at all anymore, that seems to be a bug.
David.P
PDF-XChange Pro
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8544
Joined: Wed Jan 03, 2018 6:52 pm

Re: Reverse PDF page order

Post by TrackerSupp-Daniel »

Hello, David.P

Unfortunatley no, the toolbar cannot be permanently hidden, In the classic UI, you can collapse it (With the small arrow on the far right of the toolbar), but in the ribbon UI, while the tab can be hidden, it will reappear the next time that the software restarts.
At the moment I am not sure it is possible to prevent this re-appearance, since the initial appearance is caused by the JS which is read during the launch to add these items to the toolbars at all. But I will ask the team if there is a way to offer this.

You also mention a bug wherein the toolbar cannot be "closed" anymore? Can I ask you to please elaborate on that issue? What do you mean by closed?

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

Re: Reverse PDF page order

Post by rakunavi »

Hello all,

Sorry for interrupting. There are two ways to make it faster than Radi's script above.

  • After I had finished writing this post, I realized that Method 1 had already been introduced in this forum. However, I will leave it for comparison with Method 2, which will be discussed later.
    https://forum.pdf-xchange.com/viewtopic.php?f=62&t=28407
Method 1
  • Simple JavaScript

    First, simply not displaying the progress bar will speed up the process considerably. 1,000 pages can be finished in an instant.

    Code: Select all

    for (i = this.numPages -1; i >= 0; i--) this.movePage(i);
    This one line is sufficient for the script, but if you want to display it on the toolbar, it would be as follows.

    Code: Select all

    app.addToolButton({
      cName: "Reverse Pages Order",
      cExec: "for (i = this.numPages -1; i >= 0; i--) this.movePage(i);",
      cTooltext: "Reverse Pages Order",
      nPos: 0
      });
Method 2
  • Making full use of feautres on Bookmarks tab

    You can use the features on the Bookmarks tab without using JavaScript, and it will be just as fast. Specifically, perform the following three steps in order

    1. Use the "Bookmarks Every Nth Page" feature to bookmark every page with a page number. Bookmark Title Template must include "%[Page]".
    2. After selecting the "Sort" icon to open the "Sort bookmarks" dialog, specify "Sort bookmars alphabetically" and "Descending" to sort the bookmarks.
    3. Finally, select the "Sort Pages" icon to sort the pages in the order of the bookmarks.
    figure.png

    Method 2 requires multiple operations of the dialog, which takes more time and effort, but the total time required for the sorting process is comparable to that of Method 1 because the sorting process itself is slightly faster with Method 2 than with Method 1. The difference between Method 1 and Method 2 will become more noticeable when the number of pages reaches about 10,000.

    The time required to sort 5,000 pages on a machine with i5-8265U CPU and 8GB Memory is as follows.
    ([MM:SS.SS] "MM" stands for minutes and "SS.SS" for seconds).

    • Radi's script [1:18.54]
    • Method 1 --- [0:13.55]
    • Method 2 --- [0:08.87] (only time required for step 3)
    Even if bookmarks already exist, you can still use Method 2, but I recommend using JavaScript because it requires a slight modification as follows

    • If you want to reverse order a file that already has a bookmark, create a "temp" entry with no action at the top of the bookmark, and then make bookmarks as a child of the "temp" entry (Step 1).
    • After selecting the "temp" entry, go to Step 2 and specify "Children of selected" as the Bookmark Source instead of All bookmarks.
    • Finally, after sorting the pages in Step 3, delete bookmarks under the first created "temp" entry and you are done.

For your reference, I have captured the verification of the following three methods discussed in this article when sorting 1,000 pages.

  • Radi's Script
  • Method 1: Simple JavaScript
  • Method 2: Making full use of feautres on Bookmarks tab
Note that no matter which of these three methods is used to sort the pages, the labeling of the sorted pages will be incorrect. When sorted by JavaScript (Radi's script or Method 1), the first page is labeled 2, and when sorted by Method 2, the first page is labeled 1000. Please note that "Use logical page numbers" setting is disabled by default and must be enabled to check this issue. The issue occurs only in build 363 and works fine in build 361. It seems to be a bug and may be related to the matter I reported the other day.

  • #6206: intelligently optimize page ranges.
    https://forum.pdf-xchange.com/viewtopic.php?t=39216
Hoping that the above information will be of some help to you.
Thank you so much for your continued support.

Best regards,
rakunavi

- PDF-XChange Editor Plus Version:9.4 build 363.0
- OS Version: Windows 10 Home/Pro 21H2 Build 19044.1889
- PC Model: Lenovo IdeaPad C340-15IWL / HP ProDesk 600G1
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
TrackerSupp-Daniel
Site Admin
Posts: 8544
Joined: Wed Jan 03, 2018 6:52 pm

Re: Reverse PDF page order

Post by TrackerSupp-Daniel »

Hello, rakunavi

Yes, adding the progress bar in inherently a large amount of re-checking and additional processing which causes the script to take significantly longer to execute. I would not recommend using the script with the progress bar either, although it does give a nice visual indicator of the progress, that is far less helpful when it takes 5+ times as long to complete the process.

Whichever method people choose to use, Thank you for the extra details on this topic!

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
Logilink
User
Posts: 46
Joined: Mon May 01, 2017 12:22 pm

Re: Reverse PDF page order

Post by Logilink »

Seriously, to this day there is no this simple function in this advanced pdf editor and you have to keep playing around this problem?

Ok, I have an even simpler method - using Merge Pages window.
Settings of Merge Pages:
- Type: Multiple pages...
- Pages per Sheet: Custom - 1 by 1
- check Calculate size based...
- Pages: All, Subset: All
- check "Reverse order"
- OK
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8544
Joined: Wed Jan 03, 2018 6:52 pm

Re: Reverse PDF page order

Post by TrackerSupp-Daniel »

Hello, Logilink

There a countless "simple actions" which we seem many requests for, the problem is that in creating a tool to do any one, we would eventually need to create a tool to do every one of them... You can see how this would result in a frankly ridiculous amount of tools beyond our already excessive amount. Currently most tools offer a specific use case, and these can be used to accomplish most needed functions.

If you need to perform specific actions in a very specific way, such as reversing page order, or merging two files and then re-ordering pages (IE: A1,B1,A2,B2), Etc JavaScript is typically going to be the best option, as it allows you to customize the output to fit your document(s) and your needs, opposed to having to use a chain of 5 "pre-made hype specific tools" in a certain order, to get your needed end result.

I am sorry to say that this is not likely to change in an official capacity, though we have been looking at methods to contain and offer "confirmed safe/useful user-created JS tools" for easy access.

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
Logilink
User
Posts: 46
Joined: Mon May 01, 2017 12:22 pm

Re: Reverse PDF page order

Post by Logilink »

I didn't mean to create another tool (because I also think there are too many already), but to integrate this function with the existing ones. Reversing the order suits the Move Pages tool, for example.
I was just surprised that the program does not have such a simple function while IMO having already many unnecessary and overly complicated functions.
In my method there is only one step and there is no joining pages, the result is single pages as in the original, only in reverse order.
As for javascript, it requires knowledge or searching and asking on the forum...
User avatar
Dimitar - Tracker Supp
Site Admin
Posts: 1793
Joined: Mon Jan 15, 2018 9:01 am

Re: Reverse PDF page order

Post by Dimitar - Tracker Supp »

Hello Logilink,

Unfortunately, we still do not have such a feature, but I think we will have it implemented in the nearest future.

You can as well use the extract pages tool:

image.png

Regards.
Post Reply