Spawning Template Pages to a Location Relative to Another Page
I have a form that is two related but separate report forms. Both forms are usually, but not always, filled in together, with some information common to both forms. The advantage to having both forms together in a single PDF is that the person filling out the form does not have to enter information common to both forms more than once. There are also Invoice Templates so the user can generate either one invoice or two separate invoices.
Each form has Template pages that are added as needed. The format of the PDF is:
Report 1
Additional Comments (Template)
Photos (Template)
Invoice (Template)
Report 2
Additional Comments (Template)
Photos (Template)
Invoice (Template)
When I spawn Template pages, the spawned pages all go to the end of the document. I need the Templates for Report 1 to immediately follow Report 1 and the Templates for Report 2 to immediately follow Report 2. The Photo Page Templates are usually replicated anywhere from two to 12 times for each report. It is very important to have the Photo pages with thier respective report, not all together at the end of the document.
I also need to set the security to allow filling the form, etc. so that the users of the form cannot modify the form or have access to the JavaScript. I am able to get the pages to spawn to where I need them if the security is off or set to "Any except extracting pages", but not at any othr security level.
I think I know what the problem is with what I was doing and the security. Not realizing the security limitation, I generated a new page, then overlayed the spawned page onto it. The reason I did that was that I could not figure out how to get the spawned pages to spawn to a particular location without them being overlays. My solution worked until I set the security. Apparently, it is “this(newPage(currentpage+1)” that is causing the problem (I think that's what the problem is, but I'm not sure?). Also, I looked at the Adobe JavaScript Reference. It only shows examples of spawned template pages being overlays. This is the JavaScript I used:
// Get the template name
var templateName = "PhotosWind";
// Get the current page number
var currentPage = this.pageNum;
// Insert a blank page after the current page
this.newPage(currentPage+1);
// Overlay the template page on the new blank page
this.spawnPageFromTemplate(templateName, currentPage+1, true);
Acrobat generate an error saying that security setting will not allow that. When that didn’t work, I tried this:
var templateName = "PhotosWind";
var currentPage = this.pageNum;
this.getTemplate(templateName).spawn({currentPage:+1, bOverlay: false, bRename: true});
That puts the spawned page at the end of the document instead of the page following the current page (where the button to spawn the page is located). So, I am back to my original problem of not being able to spawn a page to a particular location.
Any help will be greatly appreciated. Thanks for taking the time to read this!
