[Tool] Combine odd & even pages to single document  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] Combine odd & even pages to single document  SOLVED

Post by Mathew »

I have a single-sided scanner, so if I need to scan a two-sided document, I have to flip the stack and scan to two separate files: The odd pages and even pages. The even pages will be in reverse order. I use this tool to combine them.

To install the tool, extract the zip and save in the Javascripts folder. You may need to create a folder named 'Javascripts' if there isn't one there already:
combine even odd pages menu v0.5.zip

It will add a menu item "Combine Even Odd Pages..." under Organize ribbon (ribbon UI) or the Documents menu (classic UI).
image(1).png
To use, first open both documents -- they must be saved first -- then run the script:
image.png
Select which document is to be used for odd pages, which is even, and if either of them need the page order reversed. You can pick whether to insert the pages into one of the above documents, or create a new unsaved document that combines the files.

Limitations:
  • Files must be saved first. doc.insertPages() cannot access files that are not saved.
  • If one of the documents to be combined is longer, it puts the additional pages from the longer document at the end
  • May be rather slow on large documents
  • It doesn't handle the bookmarks: If you combine to a new document, then there will be no bookmarks. If you insert the pages into a document, it won't import the bookmarks from the other document, or change bookmark order if you change the page order.
This tool can also be used if you just want to reverse the page order of a single document (just pick that one document as the 'odd pages' document).

Maybe this is already a part of PDF-XChange and I've just not noticed - if so, let me know!
You do not have the required permissions to view the files attached to this post.
Last edited by Mathew on Tue Oct 29, 2024 9:19 pm, edited 2 times in total.
User avatar
rakunavi
User
Posts: 2119
Joined: Sat Sep 11, 2021 5:04 am

Re: Tool: Combine odd & even pages to single document

Post by rakunavi »

Hello Mathew,

Thank you for releasing this amazing script.

I have been using Alternate Mix in PDFsam Basic for about 10 years for the same purpose. However, with PDFsam, bookmarks are lost, so I had to do a separate backup and import. Since the page numbers of the linked pages would be changed after importing, I would have to export them in text format and then modify them in Excel or other software. However, PDF-XChange Editor has a unique color setting for importing bookmarks from text files, making it practically unusable for me, so I had to use JpdfBookmarks. At the same time, I was concerned that the more multiple software packages were combined, the less consistent the PDF files would be.

I have written at length, but Mathew's script does a complex process in a single step. :D

Even in the past, the same thing could be done by running a script from a console, but it goes without saying that the more routine the work, the more desirable it is to be able to execute it from a well-designed dialog.

It shines on the menu as if it were a genuine feature. Thank you so very much.

  • figure.png
Best regards,
rakunavi
You do not have the required permissions to view the files attached to this post.
Top needs 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 FullScrnMultiMon
forum.pdf-xchange.com/viewtopic.php?t=41002 DisableTouchSelect
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19930
Joined: Mon Jan 12, 2009 8:07 am

Re: Tool: Combine odd & even pages to single document

Post by Stefan - PDF-XChange »

Hello Mathew, rakunavi,

Many thanks for sharing this tool with all! I am sure this would be helpful to many!

I've had some much simple JS written - and shared here in the forums where users could e.g. merge their two files using the Editor UI and then have the pages from those rearranged with the JS, however Mathew's is certainly much neater!

@Rakunavi - you would no longer need third party products for that operation! :D

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

Re: Tool: Combine odd & even pages to single document

Post by Mathew »

Oh good, I'm glad it's useful :) I think that the bookmarks get brought along is a feature of PDF-XChange when inserting pages that I really appreciate.

@rakunavi I still use the Classic UI so I didn't realize where it shows up in the ribbon UI. Good to know it still gets added - I wish there were a way to add to specific ribbon menus the way we can on the classic. But that's another post...
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12660
Joined: Wed Jan 03, 2018 6:52 pm

Re: Tool: Combine odd & even pages to single document

Post by Daniel - PDF-XChange »

Hello, Mathew

I am also glad to see projects like this cropping up. As for your mention of the other topic, I have actually passed that to our UI dev and am just awaiting his input. Hopefully there is a way, but at the time, I do not know it. Will keep you posted in that topic as soon as I hear from him!

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

Re: Tool: Combine odd & even pages to single document

Post by PHK »

Just another thought on this topic.

if the all pages have 'correct' Bookmarks even if they are out of order (reversed, for example), there is a tool within PDF-XCE that can help without resorting to JS.

Lets say you have scanned the duplex document, first one side then the other, but with 'good' Bookmarks. You would Combine the files
image.png
and sort the Bookmarks
image(1).png
Select the Bookmarks and sort the associated pages.
image(2).png
Voila! The pages are sorted.
You do not have the required permissions to view the files attached to this post.
All best,

FringePhil
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19930
Joined: Mon Jan 12, 2009 8:07 am

Re: Tool: Combine odd & even pages to single document

Post by Stefan - PDF-XChange »

Hello PHK,

Many thanks for the post! Indeed that is also a good solution requiring only the already available tools!

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

Re: Tool: Combine odd & even pages to single document

Post by Mathew »

PHK wrote: Wed Oct 11, 2023 1:17 pm Voila! The pages are sorted.
Very nice solution :)

I didn't know about the ability to sort pages by bookmarks - that will really help when re-organizing a document (instead of dragging thumbnails around). Thanks for that -- although it only works for this case if every page has a bookmark.
User avatar
PHK
User
Posts: 1546
Joined: Tue Nov 24, 2020 4:02 pm

Re: Tool: Combine odd & even pages to single document

Post by PHK »

Mathew wrote: Wed Oct 11, 2023 6:26 pm ... Thanks for that --
You're welcome.
Mathew wrote: Wed Oct 11, 2023 6:26 pm although it only works for this case if every page has a bookmark.
Yes, that is a limitation. But there is a workaround using Bates numbering and Generate Bookmarks From Page Text. It sounds a bit complicated but it is easier than it sounds.

After you have scanned the pages once for the front side and another for the back, create Bates numbers.
image.png
Add some simple text ("Odd" for example).
image(1).png
Then do the same for the other set but use different text, "Even" for example. Use the tool.
image(2).png
Generate Bookmarks from the Bates stamps you have created.
image(3).png
Select ONLY the 'back' set of Bookmarks and sort them in reverse, or "Descending," order.
image(4).png
Then, move the back set Bookmarks to their appropriate place in the Bookmark stack.
You do not have the required permissions to view the files attached to this post.
All best,

FringePhil
User avatar
PHK
User
Posts: 1546
Joined: Tue Nov 24, 2020 4:02 pm

Re: Tool: Combine odd & even pages to single document

Post by PHK »

An an alternative to 'manually' shifting the 'back' Bookmarks would be use the Bates Stamping tool again on that set but this time running the Bates tool again but this time using the same instructions as used in the 'front' set but adding a single-letter appendage like "e". Thus, you would have the front page Bookmarks with something like
Book 1
Book 2
Book 3
Book 4
etc.

Followed by
Book 1e
Book 2e
Book 3e
Book 4e
etc.

Now, if you sort all of these Bookmarks you will get
Book 1
Book 1e
Book 2
Book 2e
Book 3
Book 3e
Book 4
Book 4e
etc.

Now, sort the pages in Bookmarks.

All those Bookmarks can be de-cluttered with a Delete of the selected Bookmarks.
All best,

FringePhil
User avatar
PHK
User
Posts: 1546
Joined: Tue Nov 24, 2020 4:02 pm

Re: Tool: Combine odd & even pages to single document

Post by PHK »

One final thought: If you don't want all these Bates stamps cluttering your document, select "None" in the "Stroke" section of "Effects" of the "Select Font" box in "Add Bares Numbering." Nothing will appear on the document but Bookmarks will still be created by Add From Text.
All best,

FringePhil
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19930
Joined: Mon Jan 12, 2009 8:07 am

Tool: Combine odd & even pages to single document

Post by Stefan - PDF-XChange »

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

Re: [Tool] Combine odd & even pages to single document

Post by Mathew »

I updated the tool so that it's shown on the "Organize" ribbon in the ribbon UI. Also some other miscellaneous changes - hopefully without introducing bugs... I also updated the first post.
combine even odd pages menu v0.5.zip
Changes
  • add icon,
  • add to ribbon UI,
  • make translateable,
  • add option of where to combine,
  • move trusted functions to private variables,
  • persist dialog options if run again before a restart,
  • check that documents are saved: doc.insertPages() loads pages from the file on disk, so unsaved changes won't get included.
You do not have the required permissions to view the files attached to this post.
User avatar
Dimitar - PDF-XChange
Site Admin
Posts: 2673
Joined: Mon Jan 15, 2018 9:01 am

Re: [Tool] Combine odd & even pages to single document

Post by Dimitar - PDF-XChange »

Thank you for your effort, Mathew.

We appreciate it.
giorgio.mp
User
Posts: 1
Joined: Thu Jul 17, 2025 10:01 am

Re: [Tool] Combine odd & even pages to single document

Post by giorgio.mp »

Thanks for the great script! If only I could find the button... I am a noob and I cannot install the script properly, any help please? :D
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12660
Joined: Wed Jan 03, 2018 6:52 pm

Re: [Tool] Combine odd & even pages to single document

Post by Daniel - PDF-XChange »

Hello, giorgio.mp

It should be as simple as placing the Js files from Mathew's above zip folder, into the "Javscripts" folder located in either your Editor install directory, or the appdata directory. Do this while the Editor is fully closed as well, since Js is only loaded on startup.

Note that Neither of these "javascripts" folders exists by default, so you will likely need to navigate to one of these two folders and create the "Javascripts" folder manually (Only place the Js file in one of these two locations, having the same file in both may cause some confusion with special scripts like this).

C:\Program Files\Tracker Software\PDF Editor
or
%appdata%\Tracker Software\PDFXEditor\3.0

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: 2119
Joined: Sat Sep 11, 2021 5:04 am

Re: [Tool] Combine odd & even pages to single document

Post by rakunavi »

Hello giorgio.mp,

If there is a trouble for new users, it might be how to open the JavaScript folder. Personally, I think the most straightforward way is to use the "App-Level Scripts" command in the JavaScript console on the Form tab.

  • figure.png
For reference, here is a video showing the series of operations.

  • Animation.gif
I cannot express my gratitude enough, but I would like to take this opportunity to sincerely thank Mathew for creating such an amazing script. :o

Best regards,
rakunavi
You do not have the required permissions to view the files attached to this post.
Top needs 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 FullScrnMultiMon
forum.pdf-xchange.com/viewtopic.php?t=41002 DisableTouchSelect
User avatar
Dimitar - PDF-XChange
Site Admin
Posts: 2673
Joined: Mon Jan 15, 2018 9:01 am

[Tool] Combine odd & even pages to single document

Post by Dimitar - PDF-XChange »

:)
Manthe
User
Posts: 9
Joined: Mon Jun 23, 2008 4:30 am

Re: [Tool] Combine odd & even pages to single document

Post by Manthe »

I wish to thank Mathew for this tool!! I too am scanning a number of large two-sided documents with a single-sided scanner (it's actually a double-sided, duplex scanner but the paper handler is unreliable in duplex mode so for all practical purposes it's largely just single-sided).
I am a long time user, using the Classic UI mode, so I very much appreciate seeing it under the Document tab, and under File -> New Document!!
Thank you to the other users also for their input.

Daniel, you noted in this thread in 2023: "I have actually passed that to our UI dev and am just awaiting his input." Any chance this can still be worked into Editor? I really appreciate that "Reverse Page Order" was added in 10.8.0.405, but going further to include the interleaved combination of files like Mathew's tool would be awesome!

I spent time digging through the PDF Exchange online help system looking for this solution, I could only find the Reverse Page Order. I then started a discussion with ChatGPT looking for input. It didn't present with anything useful. Today, after learning about this tool, trying it with files I've been working on, I went back to ChatGPT and informed it of this forum thread and further clarified it with details about how it operates. I would be curious if PDF Exchange could combine with its online help an AI Assistant using the online help and user forum in its database.

Thanks again to all!!
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12660
Joined: Wed Jan 03, 2018 6:52 pm

Re: [Tool] Combine odd & even pages to single document

Post by Daniel - PDF-XChange »

Hello, Manthe

I am glad you found the thread helpful!

As for your question - It does not look likely we will be adding more in this area. Reverse pages was added as it is something that is both very commonly needed, and most notably, easily reversed by clicking the button again. Interleaving pages however is somewhat less simple to reverse after you have saved the changes.

If you need to interleave pages, you can use the "manual duplex" option in the scan dialogue, scan the front of all sheets, then scan the back of all sheets, and the Editor will automatically adjust the order at that point.

Otherwise, for an already existing file, the JS noted before will be the best option.

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: [Tool] Combine odd & even pages to single document

Post by Mathew »

Manthe wrote: Mon Mar 16, 2026 1:26 am I wish to thank Mathew for this tool!! I too am scanning a number of large two-sided documents with a single-sided scanner (it's actually a double-sided, duplex scanner but the paper handler is unreliable in duplex mode so for all practical purposes it's largely just single-sided).
I am a long time user, using the Classic UI mode, so I very much appreciate seeing it under the Document tab, and under File -> New Document!!
Thank you to the other users also for their input.
Thanks for the note Manthe.

I have always appreciated the aspect of open source that enables tinkerers like me to tweak software to our specific use case, which may not necessarily align with the majority of users. Sometimes these tweaks do make it into the program: See for example the list of "superceded" scripts listed at the end of viewtopic.php?p=178741#p178741 Often I think it makes more sense to avoid making the software too bloated with loads of edge cases; the more features and tweaks a piece of software has, the harder it becomes to maintain, and the more opportunity for bugs and problems.

I really appreciate how supportive this forum community and Tracker software has been of the various niche tools I've made, and it makes me happy to know other people find them valuable.
User avatar
Sean - PDF-XChange
Site Admin
Posts: 900
Joined: Wed Sep 14, 2016 5:42 pm

Re: [Tool] Combine odd & even pages to single document

Post by Sean - PDF-XChange »

Hi Mathew,

Thanks for your post - we are very happy to have your excellent input into our products, and look forward to continued coordination in the future.

Kind regards,
Sean Godley
Technical Writer
PDF-XChange Co LTD
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623
arc design partnership llp
User
Posts: 4
Joined: Fri Sep 14, 2012 9:38 am

Re: [Tool] Combine odd & even pages to single document

Post by arc design partnership llp »

Excellent - very helpful. thank-you!
Gareth
User avatar
Sean - PDF-XChange
Site Admin
Posts: 900
Joined: Wed Sep 14, 2016 5:42 pm

Re: [Tool] Combine odd & even pages to single document

Post by Sean - PDF-XChange »

:)
Sean Godley
Technical Writer
PDF-XChange Co LTD
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623