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

Need assistance with spawning templates and then reorganizing the document pages

Community Beginner ,
Jan 07, 2021 Jan 07, 2021

Copy link to clipboard

Copied

Hello,

 

I have a PDF form that has hidden templates set up via JavaScript in a button. My issue is when I spawn the new template page it gets inserted at the end of the document, but i need it to spawn as the next page in the document (for example as page 3 of 97).  I was able to have the page spawn as the next page, page 3 for example, however then all the fields were being named after page 3, eg P3.Vehicle.Year. I need every spawned page to have unique values, so this wont work for me.

 

I know there must be a way of spawning template pages at the end of the document so they are assigned new field names, and only after the field names are assigned move the page (which will always be the last page) to a different page in the doc. Preferably, I would like the template spawned page to move to the page located after the button that controls the whole thing.

 

Here is the script I found on another post that I am trying to use:

 

var SpawnPage = this.getTemplate ({cName: "Template"});

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

 

I am a total beginner, so please excuse my ineptitude! And THANK YOU in advance!

 

TOPICS
Create PDFs , Edit and convert PDFs , How to , JavaScript , PDF forms

Views

469

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

correct answers 1 Correct answer

Community Expert , Jan 08, 2021 Jan 08, 2021

Yes, that can be done, and I think it should work, but as mentioned, it won't work in Reader...

To do it add this line of code to your script:

this.movePage(this.numPages-1, 1);

Votes

Translate

Translate
Community Expert ,
Jan 07, 2021 Jan 07, 2021

Copy link to clipboard

Copied

This is very problematic to achieve, exactly because of this issue. You will need to spawn the page not after the current page, but after the current page, plus all the pages you already spawned. Spawning it at the end of the file and then moving it will not solve the problem, as the field names are determined by the page number used in the spawn method.

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 Beginner ,
Jan 07, 2021 Jan 07, 2021

Copy link to clipboard

Copied

Thank you for your response. I have been reading your other comments regarding this issue as well, so I am glad to have caught your attention.

 

So it sounds like moving the page after all other spawned pages is out of the question (at least for me), but would it be possible to have a button run two sequential scripts. The first script spawns the page and establishes field names. The second script moves the last page to page 3.

 

Multiple spawns would move previous spawned pages from the page 3 position, but at least they wouldnt be at the end of the document.

 

Possible or pipe dream? Again, thank you for your help.

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
LEGEND ,
Jan 07, 2021 Jan 07, 2021

Copy link to clipboard

Copied

Acrobat can move pages, but Reader cannot. So if the form has to work with Reader, you won't be able to use that approach.

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 ,
Jan 08, 2021 Jan 08, 2021

Copy link to clipboard

Copied

Yes, that can be done, and I think it should work, but as mentioned, it won't work in Reader...

To do it add this line of code to your script:

this.movePage(this.numPages-1, 1);

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 Beginner ,
Jan 08, 2021 Jan 08, 2021

Copy link to clipboard

Copied

LATEST

Yep that did the trick. THANK YOU. You are going to make me look like a genius at work!

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