Skip to main content
Participant
October 28, 2024
解決済み

Spawning page in middle of PDF

  • October 28, 2024
  • 返信数 1.
  • 1395 ビュー

How do I spawn a page to appear in the middle of a pdf?

 

I found this Java code that spawns a page to the end of the file, while renaming all the fields.

 

var a = this.getTemplate("Template1"); //change your template name

a.spawn({nPage: this.numPages, bRename: true, bOverlay: false});

 

What do I need to change to spawn a page after page 5 the first time, and then each additional spawn will be added relative to the last page I inserted/spawned?

 

I am a beginner with Java.

このトピックへの返信は締め切られました。
解決に役立った回答 PDF Automation Station

I am spawning the same template page and I did add the button to the template page.


if(this.numPages==10)

{a.spawn({nPage: 5, bRename: true, bOverlay: false});}

else

{a.spawn({nPage: this.pageNum+1, bRename: true, bOverlay: false});}

 

Change the 10 to actual number pages in your document before any spawning is done.

返信数 1

PDF Automation Station
Community Expert
Community Expert
October 28, 2024

When the bOverlay paramater is set to false, the page is inserted as new page before the nPage parameter.  Change this.numPages to the page number that you want the page to appear before.  Example:

a.spawn({nPage: 5, bRename: true, bOverlay: false});

will spawn the page before page 6.  The other spawns will have to take the new page number of the spawned page into account.

Participant
October 28, 2024

Thank you. That worked. How do I change the code to insert additional pages? The "before" page number is not static when I want to isnert more than one page. I am not sure I am explainign this right, so forgive my ignorance....trying to learn. Much appreciated for this Community.

PDF Automation Station
Community Expert
Community Expert
October 28, 2024

Are you spawning the same template each time?  Is the spawn button located on the template page?