Copy link to clipboard
Copied
Hello,
Brand new at PDF scripting and running into an issue trying to spawn pages from template. My use case is an "Add Item" button that adds an identical form page with some fields reset. The easiest way seems like:
this.getField("Add Item").display=display.hidden;
this.templates[0].spawn({
nPage: pageNum,
bRename: true,
bOverlay: false
});
this.getField("Add Item").display=display.noPrint;
this.resetForm([
<subset of fields to reset>
])
Setting nPage to pageNum displaces the original page to the end where only it should have the Add Item button, not the spawned template pages since the fields are named differently (was not able to use wildcard).
Functionally it works. The problem comes from the display.noPrint row. Adding the button back wrecks the the original template page, but it seems to be a UI issue. Zooming/scrolling/etc restores all form fields in both Acrobat and Reader.
Any ideas what is wrong here and how to fix, or a better way altogether?
Since zooming works in the UI it also solved the problem with the script.
Added last row
this.zoom=100;
But why is this necessary?
Copy link to clipboard
Copied
Since zooming works in the UI it also solved the problem with the script.
Added last row
this.zoom=100;
But why is this necessary?
Copy link to clipboard
Copied
It shouldn't be. What does "wreck the original template page" means, exactly? What happens when you set the field as non-printing (and why not do that in the original Template page, in advance)?
Copy link to clipboard
Copied
Thanks for your reply
What does "wreck the original template page" means, exactly?
previously fillable fields look like:
until zoom/scroll, then become fillable again.
What happens when you set the field as non-printing (and why not do that in the original Template page, in advance)?
Not sure if I understood the question, the field starts as non-printing on the original page, then is hidden on spawned pages. This avoids new field names which don't match the reset array. Then bringing it back after the spawn causes the issue. Not sure if this is the right way/good practice.
Copy link to clipboard
Copied
The screenshot doesn't tell me what the issue is, I'm afraid. Could you maybe share the file with us?