• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
13

Page spawned from template not rendering

Community Beginner ,
Dec 16, 2023 Dec 16, 2023

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?

TOPICS
Create PDFs , JavaScript , PDF , PDF forms

Views

482

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Dec 16, 2023 Dec 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?

Votes

Translate

Translate
Community Beginner ,
Dec 16, 2023 Dec 16, 2023

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 16, 2023 Dec 16, 2023

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 16, 2023 Dec 16, 2023

Copy link to clipboard

Copied

Thanks for your reply

quote

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

 

previously fillable fields look like:

Screenshot 2023-12-16 at 6.51.28 PM.png

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.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 17, 2023 Dec 17, 2023

Copy link to clipboard

Copied

LATEST

The screenshot doesn't tell me what the issue is, I'm afraid. Could you maybe share the file with us?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines