insert/delet pages in several files at once

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

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

cornelia thurn
User
Posts: 6
Joined: Thu May 31, 2012 6:07 pm

insert/delet pages in several files at once

Post by cornelia thurn »

Hi Forum!

I regulary have the task to insert a blank page at the end of a pdf-file and a few weeks later I then have to delet the last blank page again. This is no problem with the pdf-xchange viewer pro!

My question is now: as I have to do this always with round 60 files, I am looking for a way to do it in one step. Normally, I open all the 60 files at once and get them as tabs in the pdf-xchange viewer. Then I choose "document, delet page 2", save, close, delet page 2, save, close, and so on till all the tabs are closed and done.
Is there a way to say "delete page 2" for every tab? And vice-verca, "add blank page at the end" for every tab? This kind of batch processing would really make my life much easier! :) Thanks for all advices in advance!

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

Re: insert/delet pages in several files at once

Post by Stefan - PDF-XChange »

Hello coko,

You can use JS in our Viewer to speed up the process.

I tried to prepare a fully automatic script for you but it seems like there are some JS methods that we still need to fine tune.

So what you can do is:
1) Open all your documents
2) Open the JS console (Ctrl-J)
3) Inset this code there:

Code: Select all

docsList = app.activeDocs;
for (var i=0; i < docsList.length; i++) 
{
  var Rect = docsList[i].getPageBox("Crop");
  docsList[i].newPage(docsList[i].numPages+1, Rect[2], Rect[1]);
}
and click the green triangle to execute the script.
4) wait for all documents to get a new empty last page, and then close the Viewer - this will ask you whether you want to save the changes. It will ask for each file individually so you will need to click the "Yes" button 60 times - but this will still speed up the process.

The reverse (to delete the last empty pages) will have the script for step 3 like this:

Code: Select all

docsList = app.activeDocs;
for (var i=0; i < docsList.length; i++) 
{
  docsList[i].deletePages({nStart:docsList[i].numPages-1});
}
Best,
Stefan
cornelia thurn
User
Posts: 6
Joined: Thu May 31, 2012 6:07 pm

Re: insert/delet pages in several files at once

Post by cornelia thurn »

Hi Stefan!

Sorry, I just read your answer today :( But as I just needed to do the insert-task now, I rememberd my question in this forum..

So, I had a real task to try your script and it works perfect! A great thank you to you :D

regards,
coko
User avatar
John - Tracker Supp
Site Admin
Posts: 5225
Joined: Tue Jun 29, 2004 10:34 am

Re: insert/delet pages in several files at once

Post by John - Tracker Supp »

Excellent - thanks Coko.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com