Spawning Blank Fillable Form Pages
- May 25, 2023
- 1 reply
- 626 views
Hello!
I am a teacher, and not a PDF expert of Java expert. I would love some help for a form I am working on.
What I need:
I have a form that I have to fill out for multiple students. Instead of filling out the form once, saving and then doing another form, I would love a way to spawn a new duplicate page in the form in the same document that I can then fill out for another student.
Where I am at: Based on some posts I saw I was able to add a button to my form using a Javascript. I was able to create a template from my form and the template is hidden. When I hit the button to add a duplicate page, it does it beuaitfully. I get a new duplicate page that I can fill in and it does not interfere with the other pages.
The problem: When I open this form for the first time, it automatically opens with TWO pages instead of one. Whatever I type in page 1, goes directly on to page 2 as well. I can add the new page with the button and page 3,4,5,6,etc., can all be different for different students. I am just wondering why it always opens with two pages instead of one (even after I delete page 2 from the organize pages tool and resave it as a new file). I have even attemped to change the field names of page 1 and 2 to be different so it didn't duplicate the information. That worked, excpet when I saved it and opened it again it now had 3 pages and page 1 and 2 were still identical copying each other. Any ideas why I am getting two pages to begin with and how to get rid of that second page to start? Below is the thread and code I used to get where I am. Thank you so much!
Code/Thread:
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 from the 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});
