How do I spawn a new page in a form and place it at the end of the file without including text already entered in

I am using Acrobat XI and want to be able to use the form and additional pages in Adobe Reader.


Michael Gold


5 Answers

This is not possible with version earlier than XI or Acrobat 5 or better.

You first need to create the form and then make that page a template and include a button to add a new page with the following script:

//get the template object;
var a = this.templates;
// create a new page from the templagte at the end of the PDF;
// rename the fields, do not overlay;
a[0].spawn({nPage: this.numPages, bRename: true, bOverlay: false});

Open the JavaScript console and run the following script to spawn the first page of the form before the template:

//get the template object;
var a = this.templates;
// create a new page from the templagte at the end of the PDF;
// rename the fields, do not overlay;
a[0].spawn({nPage: -1, bRename: true, bOverlay: false});


Now hide the template. If you have any calculations you will need to rewrite the code to adjust for the renaming of the fields using the page number where inserted and the name of the template used to create the page.


George Kaiser   

The script to create a first page from the templates is:

//get the array of the template object for the PDF;
var aTemplates = this.templates;
// create a new page from the first template placing it at the end of the PDF and renaming the fields;
// rename the fields, do not overlay;
aTemplates[0].spawn({nPage: 0, bRename: true, bOverlay: false});

You can hide the template and run this code from the console.

The code to spawn a template fromt he button should read:

//get the array of the template object for the PDF;
var aTemplates = this.templates;
// create a new page from the first template placing it before the template and rename the fields;
// rename the fields, do not overlay;
aTemplates[0].spawn({nPage: this.numPages, bRename: true, bOverlay: false});


George Kaiser   

From a question fragment:

Question Title:

Spawning a form without including the text that had been entered before the spawning

Question Details:

George,

I really appreciate your swift help. However, the code you sent generates a new page, but if the user has already filled in the form that content is shown on the spawned page in the text boxes. I need a page that reproduces the blank form page I use as a template. This is so the user can fill in the form and then decide he needs an additional page of the form which will not have the answers he's already entered on the first page.

Maybe I'm just showing my ignorance, so bear with me.

Mike


David Austin   

Michael,

The link to your original question (this thread) is:

http://answers.acrobatusers.com/ViewQuestion.aspx?questionid=194936

Use the "Answer" button or the "Comment" link to maintain your question thread. Opening new threads for the same topic very much confuses things. It becomes too awkward for those interested in your question to follow. Typically they end up ignoring it all.

Be well...


David Austin   

The crucial point to avoid already entered data when spawning a Template page is to never fill out the Template page.

That means, you create the Template page, make it hidden, and then when you need that page in you initial form, spawn it (using the Console, if needed), and make sure that you do rename the fields. When you spawn again, you will spawn from an unmodified Template page, and your problem is kind of solved.

Hope this can help.

Max Wyss.


Max Wyss   


Please specify a reason: