Template methods

spawn

spawn

5.0

D 

 

F 

Creates a new page in the document based on the template.

Parameters

nPage 

(optional) The 0-based index of the page number after which or on which the new page will be created, depending on the value of bOverlay. The default is 0.

bRename 

(optional) Specifies whether form fields on the page should be renamed. The default is true.

bOverlay 

(optional) If true (the default), the template is overlaid on the specified page. If false, it is inserted as a new page before the specified page.

To append a page to the document, set bOverlay to false and set nPage to the number of pages in the document.

Note:For certified documents or documents with “Advanced Form Features rights”), the bOverlay parameter is disabled. A template cannot be overlaid for these types of documents.

oXObject 

(optional, Acrobat 6.0) The value of this parameter is the return value of an earlier call to spawn.

Returns

Prior to Acrobat 6.0, this method returned nothing. Now, spawn returns an object representing the page contents of the page spawned. This return object can then be used as the value of the optional parameter oXObject for subsequent calls to spawn.

Note:Repeatedly spawning the same page can cause a large increase in the file size. To avoid this problem, spawn now returns an object that represents the page contents of the spawned page. This return value can be used as the value of the oXObject parameter in subsequent calls to the spawn method to spawn the same page.

Example 1

Spawn all templates and appends them one by one to the end of the document.

   var a = this.templates;

   for (i = 0; i < a.length; i++)

      a[i].spawn(this.numPages, false, false);

Example 2 (Acrobat 6.0)

Spawn the same template 31 times using the oXObject parameter and return value. Using this technique avoids overly inflating the file size.

   var t = this.templates;

   var T = t[0];

   var XO = T.spawn(this.numPages, false, false);

   for (var i=0; i<30; i++) T.spawn(this.numPages, false, false, XO);