Copy link to clipboard
Copied
Hello,
I've been playing around with templates in my documents for a while and using them as temporary image selection/extra option areas by spawning and deleting copies of a hidden template in the document.
I was told deleting a page spawned from a template can cause issues after a while due to the fields having a Prefix 'p#.templatename.fieldname' and can sometimes duplicate or become greater than the actual page number.
To get around this I was wondering if you can set a spawned page to a template inside reader with a JavaScript then hide/unhide it as and when needed rather than re-spawning and deleting multiple times or if there was another system to use that could make this method more reliable.
I intend to have these pages spawn and be deleted any amount of times as the other user may desire to make multiple changes or even correct an incorrect selection.
The original question was posted on the AcrobatUsers Answers forum which sadly closed down recently, I'll place a link to the old question for reference.
Using Javascript and Templates (JavaScript)
Any help would be much appreciated.
Thank you in advance.
The logical page numbers (that's not the ones printed on the page) start with 0 for the first page, 1 for the second page, and so on.
The prefix in the field names on spawned pages with the rename option on contains the logical page number of the spawned page, when it is spawned.
In other words, if you spawn a page after (logical) page 3 (in other words, between (logical) page 3 and 4), the spawned page will have the logical page number 4, and therefore the prefix will read P4. The former page wit
...Copy link to clipboard
Copied
I am the author of the answer in the answers.acrobatusers.com forum message. There is not that much to add; just maybe to repeat.
In Reader XI and newer, it is possible to spawn Template pages. It is also possible to delete spawned pages, but ONLY in the (Reader) session in which the page has been spawned. I am not quite sure whether even saving makes it impossible to delete.
The page number encoded in the prefix of a spawned field is just a label; it does not have any logical connection to the page number of the spawned page. Let's say, you have spawned a page, and the prefix became P5, it does not matter whether the actual page is still page with logical page number 5; the fields work properly (this scenario could happen if you insert pages before that spawned page.
The purpose of the rule of thumb why the page number in the prefix should not be greater than the actual logical page number is simply to prevent duplicate field names (when they should not be duplicated).
The procedure to safely deal with spawning and deleting spawned pages is described in the forum message (save all field values, delete all spawned pages, respawn and refill the fields).
Hope this can help.
Copy link to clipboard
Copied
Thank you for your answer (again) I'm still trying to wrap my head around exactly what happens when spawned pages are spawned and deleted. Could you give me an example of saving data to a variable? I'm unsure exactly what that means.
Could you also elaborate on how Reader organises the P#? Does it start from p0 and go up as each is spawned regardless if previous pages were deleted or does it reset as you delete pages? E.g 3 spawned pages, p0, p1, p2, I delete p1, if I spawn it again does it spawn as p1 or p3?
The spawning from templates is working fine for now but I'm wanting to add more functionality to it and I'm trying to understand it's finer details so if it breaks I can understand why and try to fix it.
Copy link to clipboard
Copied
The logical page numbers (that's not the ones printed on the page) start with 0 for the first page, 1 for the second page, and so on.
The prefix in the field names on spawned pages with the rename option on contains the logical page number of the spawned page, when it is spawned.
In other words, if you spawn a page after (logical) page 3 (in other words, between (logical) page 3 and 4), the spawned page will have the logical page number 4, and therefore the prefix will read P4. The former page with logical number 4 has now the logical page number 5.
Let's have a look at the page order
Page label a b c d e
logical page number 0 1 2 3 4
Now, spawn page q after page d (logical 3):
Page label a b c d e
logical page number 0 1 2 3 4
^
spawn here
This leads to:
Page label a b c d q e
logical page number 0 1 2 3 4 5
Prefix P4
Now, spawn page q again, after the first page q:
Page label a b c d q q e
logical page number 0 1 2 3 4 5 6
P4. P5.
Delete page b:
Page label a c d q q e
logical page number 0 1 2 3 4 5
P4. P5.
Now, spawn page q once more, after the last spawned page q:
Page label a c d q q q e
logical page number 0 1 2 3 4 5 6
P4. P5. P5.
And now, the fun starts…
Copy link to clipboard
Copied
Okay I see so to stop a page duplicating field names you either have to spawn the page from the last spawned page, so from p5 not p4, or delete p5 before spawning again from p4? Same for spawning from hidden templates I assume.
I've just re-read it, its because a page was deleted before the new spawned page causing the newly spawned page to pull a page number that's already been pulled causing the duplicate, It's starting to make a lot more sense now. I won't be deleting any 'main' pages, pages not spawned from a hidden template. So as long as I make sure that any deleted pages are only deleted in a backwards order I should be okay?
Copy link to clipboard
Copied
As long as you make sure that always the last spawned page gets deleted, you should be fine. Otherwise, as stated earlier, save all spawned (and non-spawned if necessary) pages' field values, delete all spawning pages, respawn and refill.
Copy link to clipboard
Copied
Thank you very much for the explanations and your patience it all makes a lot more sense now!
Copy link to clipboard
Copied
Reader cannot create or show/hide template pages, so you won't be able to use those approaches. You may be able to use custom dialogs and import images to hidden buttons, but without more information I can't be more specific.