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

Spawning page in middle of PDF

New Here ,
Oct 28, 2024 Oct 28, 2024

Copy link to clipboard

Copied

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.

TOPICS
How to , JavaScript , PDF forms

Views

339

Translate

Translate

Report

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
1 ACCEPTED SOLUTION
Community Expert ,
Oct 28, 2024 Oct 28, 2024

Copy link to clipboard

Copied

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.

View solution in original post

Votes

Translate

Translate

Report

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 ,
Oct 28, 2024 Oct 28, 2024

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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
New Here ,
Oct 28, 2024 Oct 28, 2024

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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 ,
Oct 28, 2024 Oct 28, 2024

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
New Here ,
Oct 28, 2024 Oct 28, 2024

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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 ,
Oct 28, 2024 Oct 28, 2024

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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
New Here ,
Oct 29, 2024 Oct 29, 2024

Copy link to clipboard

Copied

LATEST

Thank you. This worked like a charm.

Votes

Translate

Translate

Report

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 ,
Oct 28, 2024 Oct 28, 2024

Copy link to clipboard

Copied

You have to make sure you're always spawning the new pages after all the other pages you've previously spawned, or you'll get duplicate field names on them.

Votes

Translate

Translate

Report

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