Skip to main content
Participant
Sep 22, 2020 1:00 AM UTC
Answered

Javascript automatically spawn new page if javascript code runs out of room on current page

Hello, I have a PDF with 20 options and each option gives the user to personalize the option. I am going to use javascript to populate a receipt based on the options selected. Most will select a few options but if someone wants all 20 options, I will run out of room on a single page to list out the details. Can someone point me in the right direction to spawn a new template automatically?

This topic is closed to new replies. Start a new post to keep the conversation going.
ls_rbls
ls_rblsCorrect answer
Community Expert
Sep 22, 2020 3:40 AM UTC

See the Adobe Acrobat SDK JavaScript API Reference, "Template", starting on Page 662 and see examples for "spawn" method examples in page 663. Below is Example 2 taken from page 663, it copies the same template 1 time for the current page, for example.

 

var t = this.templates;
var T = t[0];
var XO = T.spawn(this.numPages, false, false);
for (var i=0; i<1; i++) T.spawn(this.numPages, false, false, XO);

 

You may want to add a conditionto have this script or similar execute when a user selects all 20 options in your PDF.

Technical Generalist

1 reply

ls_rbls
Community Expert
ls_rblsCommunity ExpertCorrect answer
Community Expert
Sep 22, 2020 3:40 AM UTC

See the Adobe Acrobat SDK JavaScript API Reference, "Template", starting on Page 662 and see examples for "spawn" method examples in page 663. Below is Example 2 taken from page 663, it copies the same template 1 time for the current page, for example.

 

var t = this.templates;
var T = t[0];
var XO = T.spawn(this.numPages, false, false);
for (var i=0; i<1; i++) T.spawn(this.numPages, false, false, XO);

 

You may want to add a conditionto have this script or similar execute when a user selects all 20 options in your PDF.

Translate
Technical Generalist