Merge (combine) all opened files

The PDF-XChange Viewer for End Users
+++ FREE +++

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

amccc
User
Posts: 2
Joined: Thu Sep 21, 2023 2:51 pm

Merge (combine) all opened files

Post by amccc »

Hi. My goal is to combine all opened files into new single file. I want to receive all unsaved changes to new file too.

Code: Select all

var myPath = "temp.pdf";
var newDoc = app.newDoc();
var ad = app.activeDocs;
              for (var i = 0; i < ad.length; i++)
              {
	       res = ad[i].extractPages({cPath:myPath});
               newDoc.insertPages({ cPath: myPath });  
              }
I expect extractPages() to be silent, but it keeps asking about file overwrite and also opens a new tab with extracted data.

1. Can I achieve my goal without extractPages?
2. If not, can I make extractPages silent&overwrite?
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8624
Joined: Wed Jan 03, 2018 6:52 pm

Re: Merge (combine) all opened files

Post by TrackerSupp-Daniel »

Hello, amccc

I should first mention that the Viewer is roughly a decade discontinued, and may not work properly in modern operating systems. Ideally, you should upgrade to the PDF-Xchange Editor, to replace that, and gain access to a more robust feature set.

Now, onto the issue at hand, Extract pages will create a new external document, it is not something which can be used for a combine function reliably without additional steps after the fact and some clear renaming rules which make use of macros (that I am unsure if the Viewer offers).
To accomplish this, you will want to use the Editor. Within that application, you will need to save the unsaved changed first, then you will instead use the "File > new document > combine files" function. If you have all of these documents opened, you can click the "files" dropdown, and there is an option to "add all open files" which you can use to quickly pull all of them into the process for merging.

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
amccc
User
Posts: 2
Joined: Thu Sep 21, 2023 2:51 pm

Re: Merge (combine) all opened files

Post by amccc »

Dear Daniel,
yes, I know Viewer isn't supported anymore, but I still like it for blazing-fast speed.

Indeed, the Viewer already has built-in "Document > Insert pages..." function. It allows to copy pages between opened documents, even with unsaved changes. So, technically, Viewer is able to do exactly what I need. Now I only want to automate function with a script.

Maybe you'll ever have a chance to look inside built-in "Insert pages..." function to check how it works.
Does it extract Source pages to temporary file, before inserting into Target?
If so, maybe I can repeat that, but how to prevent Viewer to automatically open extracted Pages?

I don't highly expect answers, due to Viewer end-of-support, but I will still try to achieve that.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London

Re: Merge (combine) all opened files

Post by Tracker Supp-Stefan »

Hello amccc,

As Daniel already said - the Viewer has been discontinued for over a decade now - so there will be NO changes to features of it. If there is ever any new build - the most that such a new build would do is e.g. add support for a new style serial numbers if we switch to using such. Features of the Viewer won't see changes or updates.

The "Insert Pages" would read the pages from your source document and then add copies of those to the target file. It will read the state of the file as saved on the disk - hence why you need to save changes first before you insert the updated page to a new file.

Kind regards,
Stefan