Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Participant ,
Aug 21, 2024 Aug 21, 2024

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

TOPICS
Edit and convert PDFs , How to , JavaScript , PDF , Standards and accessibility
2.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 21, 2024 Aug 21, 2024

Any Help Here !!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 21, 2024 Aug 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 21, 2024 Aug 21, 2024

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 21, 2024 Aug 21, 2024

With the New Acrobat disabled, open the pages panel on the right, right-click a page and select Replaces Pages.  Browse your hard drive for the file containing the page you want to use to replace the page in the document.  Select the correct pages to replace and replace with.  Repeat for the other pages.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 21, 2024 Aug 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 ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 21, 2024 Aug 21, 2024

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 21, 2024 Aug 21, 2024

Thanks for your great help

Excuse me , I need a clearly understanding about 2 files

Firstly when getting the path ... do you mean file that have multiple pages or the file that contain the page the I will use it to replace

I have misunderstaing , It is the first time to use console in acrobat pro

sorry 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 21, 2024 Aug 21, 2024

The file that contains the page you will be using.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 21, 2024 Aug 21, 2024

I got this error

ReferenceError: pth is not defined
1:Console:Exec
undefined

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 21, 2024 Aug 21, 2024

You have to run the first line in the console when you are in the document for which the pages will be replaced.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 21, 2024 Aug 21, 2024

Are you mean ?

var pth="path";

I run it : error undefined

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 21, 2024 Aug 21, 2024

Undfined is correct when definining a variable.  Now run the rest of the script.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 21, 2024 Aug 21, 2024

when I run the rest of the script

for ex :

this.replacePages(3, pth, 0,0);
this.replacePages(4, pth, 0,0);

It replaced page 5 only , other pages remain no change

Is there a simplifier method to delete pages using the script directly

I mean as a beginner , when I wote in script page number 5 ... it directly delets this page

and Is this script can have a simple interface like indesign , photoshop , and illustrator

Thanks for your patience

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 21, 2024 Aug 21, 2024
LATEST

Page numbers are zero-based so you have to subtract 1 from the actual page number (example:  0 is page 1, 1 is page 2, etc.).  It sounds like you only ran the last line of the code.  To run all lines you have to select them all before pressing the Enter key on the number keypad (or Ctrl + Enter).  Other wise you have to run each line by putting the cursor on each line and pressing the num keypad Enter key.  Why do you want a script?  You can add the pages in the pages panel by dragging your 1-page file into the panel, then delete the page it is going to replace by selecting it in the pages panel and pressing the delete key.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines