Skip to main content
Inspiring
August 21, 2024
Question

how to replace certain pages with one page at the same time ?

  • August 21, 2024
  • 2 replies
  • 4621 views

Hi 

I have pdf file of 400 pages , I want to replace certain pages with one page from another file

Ex : I want to select page 4 , 16 , 50 , 60  at the same time , replace them with one page

I mean that the page from the the other pdf file is to duplicate , put instead of the selected pages

Thanks

This topic has been closed for replies.

2 replies

PDF Automation Station
Community Expert
Community Expert
August 21, 2024

Do either of the pages (old and new) have form fields or comments that you want to keep or add?  Your answer depends on the solution.

Inspiring
August 21, 2024

No , It don't contain any form fields or comments

PDF Automation Station
Community Expert
Community Expert
August 21, 2024

Thanks for your replay

Sure , I made it but I don't want to repeat the whole process for each page

Is there such a script to do this step automatically not manually ?


First get the path to the document you are using for a replacement by opening it and running the following script in the console:

this.path;

Next, open the document for which the pages will be replaced.  Run the following script in the console, adding the path from the previous step betweent the quotes:

var pth="";

Run the following lines of code in the console:

 

 

 

 

this.deletePages(3); this.insertPages(2, pth, 0,0);
this.deletePages(15); this.insertPages(14, pth, 0,0);
this.deletePages(49); this.insertPages(48, pth, 0,0);
this.deletePages(59); this.insertPages(58, pth, 0,0);

 

 

 

 

 

The 0,0 is the page range of the document to insert (that is, page 1).  If it is another page, change these using the zero-based index of the page.

Or you can use this:

 

this.replacePages(3, pth, 0,0);
this.replacePages(15, pth, 0,0);
this.replacePages(49, pth, 0,0);
this.replacePages(59, pth, 0,0);​

 

This also assumes page 1 of the source document is used.

Inspiring
August 21, 2024

Any Help Here !!