[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

Mathew
User
Posts: 581
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: 1680
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 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
Stefan - PDF-XChange
Site Admin
Posts: 19874
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
Mathew
User
Posts: 581
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: 11052
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: 1400
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: 19874
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
Mathew
User
Posts: 581
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: 1400
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: 1400
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: 1400
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: 19874
Joined: Mon Jan 12, 2009 8:07 am

Tool: Combine odd & even pages to single document

Post by Stefan - PDF-XChange »

:)
Mathew
User
Posts: 581
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: 2210
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.