Copy link to clipboard
Copied
Hi,
I have a pdf form document in which there's checkboxes that add a page after a certain page based by their number in the order of appearance. My code is :
var a = this.getTemplate ("AddPage11");
a.spawn(3, false, false);
this.pageNum = 1
And it works. But I have several checkboxes like this and so for the subsequent checkboxes that add pages, the order of appearance is conditional to the choice that the user made by clicking on a prior checkbox. Is there a way that a javascript can add pages conditionally to a prior checkbox adding pages being checked ?
Copy link to clipboard
Copied
You could enable/disable or show/hide the checkboxes based on previous checkbox values.
Are the pages also deleted if the checkbox is turned off?
If there are several templates and associated checkboxes, then this process of spawning and deleting will need to be managed carefully. For example after two pages are spawned, the first checkbox may need to be blocked so the first page is not deleted before the second page.
Copy link to clipboard
Copied
No, the pages are neither deleted, nor hidden. In fact, when you click on a check box, it creates a template page saved with the function Organize Pages. However, if I click on the checkbox and it creates a page after the first page, every other page that were already visible on the document move from one page, because the new page is the second page now. If on page 4, there's a checkbox to add a page after page 7, page 7 is now page 8, because of the page that got added, so the page that was added after page 7 is now shifted.
Copy link to clipboard
Copied
You misunderstand me.
If it is necessary to control the order of page spawning, then one strategy is to hide the checkboxes that trigger the spawn of a particular page so they cannot be clicked until conditions are right for that to happen.
Alternatively, if the goal is to place the spawned page at a particular location (which may change because of other spawned pages) then markers can be placed on the existing pages to identify the spawn locations. The best option for a marker is to use a form field. For example, if the spawned page is to be placed on the page after the page with the checkbox that spawns it, then the checkbox itself is the marker.
this.getTemplate ("AddPage11").spawn(event.target.page+1, false, false);
Or if the target page is somewhere else, a hidden button field could be placed on the page after which the template is to be placed.
Copy link to clipboard
Copied
Ah okay, I understand, but in my case it'll be hard, because the two checkboxes that add pages are on two pages that are visible when the document opens and it would be inadequate to put a button or a checkbox on the first one, so that the second page with the checkbox that add pages appear depending of the context.
Copy link to clipboard
Copied
Please explain exactly (and simply), how the spawned pages are placed.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
That doesn't tell me anything.
Are the pages supposed to be added in a specific order?
Are they always added to the end of the document?
Are there going to be more than just these 2 templates?
Copy link to clipboard
Copied
The pages are as follows : Page 1 - 1. informations; Page 2 - 1.2. Informations on the delivery compagny; Page 3 - 2. Product; Page 4 - Other Product. There's gonna be other pages of products very similar to page 4 after page 4. Page 4 should always come after page 3, and page 2 should always come after page 1. However, Page 2 is not necessarly going to be present everytime this form is completed.
Copy link to clipboard
Copied
Now, do you want to stop Page 4 from being spawned if Page 3 hasn't been spawned? Or can page 4 be spawned first, then page 3 will be inserted before Page 4? And what happens if the user goes back and checks "No" for one of the options? Does the associated page stay in place?
When there is a complex arrangment of elements that are controled though programming (any kind of element, not just pages) then it is necessary to have a complete description of the behavior.
Copy link to clipboard
Copied
Actually I found a way thank you !
Find more inspiration, events, and resources on the new Adobe Community
Explore Now