Acrobat Templates
Spawning Templates
9
Spawning Templates
Dynamic Form Field Generation
When spawning templates, you may specify whether the form fields are renamed on the
new page or retain the same names as those specified in the template. This is done through
the optional
bRename
parameter. If you set the parameter’s value to
true
, the form fields
on each spawned page have unique names, and values entered into any of those fields do
not affect values in their counterparts on other pages. This would be useful, for example, in
forms containing expense report items. If you set the parameter’s value to
false
, the form
fields on each spawned page have the same name as their counterparts on all the other
spawned pages. This might be useful if you would like, for example, to duplicate a button or
display the date on every page, since entering it once results in its duplication throughout
all the spawned pages.
Suppose the
bRename
parameter is
true
and the field name on the template is
myField
. If the template is named
myTemplate
and is spawned onto page 4, the new
corresponding field name is
P.4.myTemplate.myField
. The page number embedded
in the new field guarantees its uniqueness.
Dynamic Page Generation
When templates are used to spawn new pages, those pages contain an identical set of form
fields to those defined in the template. Depending on the parameters used, this process
may result in a size inflation problem. This is because there are two ways to specify page
generation: one option is to repeatedly spawn the same page which results in the
duplication of
XObject
objects (external graphics objects), and the other is to generate
page contents as
XObject
objects, which only requires that those objects be
repositioned.
The
nPage
parameter is used to specify the zero-based index of the page number used to
create the page. If the
bOverlay
value is set to
true
, the new page overlays onto the
page number specified in the
nPage
parameter. If the
bOverlay
value is set to
false
,
the new page is inserted as a new page before the specified page. To append a page at the
end of the document, set the
bOverlay
value to false and the
nPage
parameter to the
total number of pages in the document.
Acrobat JavaScript Scripting Guide
157