Skip to main content
Participant
December 16, 2023
Answered

Page spawned from template not rendering

  • December 16, 2023
  • 1 reply
  • 1552 views

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?

This topic has been closed for replies.
Correct answer Daniel34305200bowp

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?

1 reply

Daniel34305200bowpAuthorCorrect answer
Participant
December 16, 2023

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?

try67
Community Expert
Community Expert
December 16, 2023

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)?

Participant
December 17, 2023

Thanks for your reply

quote

What does "wreck the original template page" means, exactly?

 

previously fillable fields look like:

until zoom/scroll, then become fillable again.

quote

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.