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

New Here ,
Sep 21, 2020

Copy link to clipboard

Copied

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?

Adobe Community Professional
Correct answer by ls_rbls | Adobe Community Professional

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.

TOPICS
Acrobat SDK and JavaScript

Views

28

Likes

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

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

New Here ,
Sep 21, 2020

Copy link to clipboard

Copied

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?

Adobe Community Professional
Correct answer by ls_rbls | Adobe Community Professional

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.

TOPICS
Acrobat SDK and JavaScript

Views

29

Likes

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
Sep 21, 2020 0
Adobe Community Professional ,
Sep 21, 2020

Copy link to clipboard

Copied

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.

Likes

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
Reply
Loading...
Sep 21, 2020 0