Page templates and their elements are used to control product builds (info objects). You can turn any InDesign® document into a page template. Simply select the menu
Use document as page template
of the Page Templates panel or the Page Elements panel. The document is then immediately made into a page template. Select the menu again to revert this. All settings in both the "normal document" and the page template and its elements are carried over (also see here).
The Plug-In PageTemplates provides two panels :
The panel lists the page templates stored in the current data pool. With the upper two input fields you can search for specific entries. The search is case insensitive.
With the delete button the selected list entries can be deleted. To delete, the Alt Key has to be held down. The selected entries are deleted from the data pool.
[Since Version 3.1, R1956, 17. June 2010] Before a template is deleted with the data pool can be queried wether this is allowed. The required instructions for this are stored in
Panelstatement 120
The statement may be a data base command (or a SOAP call in SOAP) or a cScriptt.
Selects and SOAP calls contain a question mark ? which is replaced by the template's ID. A single result column of type string is expected, see here.
The following statement forbids deletion of any templates.
select "beep" from pagetemplates where id = ?
The check whether a template may be deleted is usually relatively complex. This why you can also use cScript to make more elaborate checks. In all cases, you have to set the return variable gResult (of type char[5000]) to one of the values detailed below, if the template's deletion should be prevented. The following global variables are defined in these scripts:
Variable | Type | Description |
gRecordID | int | ID of the template |
gRecordStringID | char* | Name of the template, !readonly! |
gResult | char[5000] - Return value | You can find a list of accepted values and thir meanings in the table Result String |
This script forbids deletion of templates with odd IDs.
int main () { if (gRecordID % 2) sprintf (gResult, "Templates with odd IDs (%d) may not be deleted", gRecordID); return 0; }
Result String | Description | |
Empty, NULL, or no result found | The template may be deleted | |
"beep" | Template may not be deleted | The failure to delete is communicated with a beep sound. |
"no_message" | The deletion attempt is ignored | |
other | The message is shown in a warning dialog. |
Previews and the backup copy of the original file are not removed from XML and SOAP data pools. They are, however, overwritten when the entry's ID is reused.
[since v3.4 R5942] Each page template can be linked with a script. In the upper part of the Page Elements panel, there's the popup menu After apply:
Select one of the available scripts here. The selected script will run whenever the template is applied to a page. It is called for manual applications, but also product build, reorganization and calls to page::set_info with the info string "id".
In the script, you can also chhange the document, e.g. by adding or updating frames and page headings.
Scripts, that should run when applying page templates are, as usual, defined in actions and have the ClassID 54. The popup menu Page Script is automatically filled with all actions defined this way.
Warning I: If the script creates new frames overlapping with product frames, this hinders product builts - which only build in empty spaces. To prevent this, these scripts should create frames on their own layer, and specify that layer as a layout layer in product builds.
Warning II: To prevent creating frames multiple times, frames created here should be marked accordingly. In the example below, the function frame::set_script_tag is used. There are other solutions to this problem, of course.
Variable | Type | Description |
gRecordID | int |
If gProduct is empty, the ID of the first product on the current page is determined. This requires collecting existing page content and sorting by page element. The first product ID found will be used. If gProduct is non-empty, the variables contain the ID of this product. Do not change gRecordStringID! |
gRecordID2 | ||
gRecordID2 | ||
gRecordStringID | char* | |
gProducts | ProductList |
Current, complete list of products to build, including all page templates and the current product. Do not delete list or product! Changes made on the list or the product will change the result of the build. Changes to the list position e.g. by productlist::first will be reset since v4.1 R22201 after the end of the script. In prior versions you have to reset the list position by or any other appropriate instructions. Only defined in calls by the product build (gScriptType = 2 or 3). |
gProduct | Product | |
gScriptType | int |
1 : Page template is set manually or with page::set_info |
gPage | int |
Current page number, 1 based |
This script first searches for old frames it created itself in earlier calls, using the functions frame::set/get_script_tag. All of these frames are deleted. Then a normal template is inserted and loaded. To find these frame in later calls to the script, the new frames are finally tagged accordingly.
#include "internal/types.h" char stKey [] = "Comet_Pagetemplate"; char stLayer [] = "Page_Background"; int stTemplateUD = 62; float stX = 36.0; float stY = 36.0; int main () { ItemList pl = itemlist::pageframes (gPage); ItemRef fr = item::alloc (); int i; // Delete all frames possibly created by this script for (i=0; i< itemlist::length (pl); i++) { itemlist::get (pl, fr, i); if (strcmp (frame::get_script_tag (fr, stKey), "YES") == 0) { frame::remove (fr); } } itemlist::release (pl); // Insert a template on a new layer layer::add_i (stLayer, 0); pl = document::place_items (0, "", "", stTemplateUD, stX, stY, gPage, stLayer, gRecordID, gRecordID2, gRecordID3, gRecordStringID, 1, 3); // auto load all placeholders of class 3 // Mark all frames such that they are found deleted on the next call. for (i=0; i< itemlist::length (pl); i++) { itemlist::get (pl, fr, i); frame::set_script_tag (fr, "YES", stKey); } itemlist::release (pl); return 0; }
The Page Elements panel shows the page elements (frames) of the current document page in InDesign®. It does not show the page template data stored in the data pool.
In the top part of the panel you can see the settings for the page currently shown in InDesign®, for left/right pages and for left/right continuation pages. The preview of the page template is highlighted with a grey frame.
Document pages that are not linked to a page template show this information in the page background. In the context menu, simply click
Context Menu > Show Page Templates
In the settings for the page you can see a list of all elements on the page. This list, too, shows the information from the InDesign® document, not the data pool! The list is usually reloaded on demand automatically. With you can force a reload.
You can select multiple entries in the list simultaneosly. The selection always shows the frames selected in the documentm i.e. selecting list entries selects the corresponding frames in the document. The small image in the second column of the list helps you locate the frame on the page:
The list is sorted by the order of the elements. The elements can be reordered with the buttons and .
In the lower section of the panel, the properties of the first selected list entry are shown. Changing values here will affect all selected entries. The changes are immediately displayed in the document.
In the priint:comet plugins, the elements are used exclusively by their sequence number (which results from the sequence in the list). The names of the elements are of no importance here. However, some applications in the PubServer address the elements by their names (which are this case also consist of the sequence number). To transfer the sequence number to the names, proceed as follows:
If the option Check size is enabled, the inserted product must fit completely in the page element.
If the option is deselected, the product only has to fit on the current page. As page size the bleed of the page is used. Using the option Limited by margins you can shrink the page size to the page margins (since v4.1 R22300).
When converting a document to a page template, all frames in the document are presented as page elements :
In the upper part of the page templates, the area occupied by the frames is shown. The value set in the X axis is used as a unit. The following two values indicate what fraction of the current page / all frames is occupied by the frame. Overlap and multiple overlap are both considered. The values are updated automatically when changing the size of frames on the same page.
The calculations are based off of the rectangular base area of the frames. For sheared frames, polygons, circles, ... the bounding box is used.
Forr these panels, no panel statements or actions are required.
In XML, you can start working immediately without any installation (assuming you have the plugin PageTemplates in your Comet directory). All required files and subdirectories are created automatically.
When saving page template files, the file pagetemplates.xml is created in your data folder automatically if it does not already exist. To store previews and backups, the folders pagetemplates/data and pagetemplates/previews are also created.
In SOAP, you have to checkin the file in the SOAP service with the FileID pagetemplates.xml. This is easily accomplished as follows :
When connecting to a database, you have to create the table pagetemplates. It should contain one entry with ID 0.
Field | Type | Null | Default | Remarks |
ID | int | No | 0 | Unique Index |
OwnerID | int | Yes | 0 | Documents may contain multiple page templates. Only the document with the first one is saved. |
PageWidth | float | Yes | NULL | in points |
PageHeight | float | Yes | NULL | |
PageNum | int | Yes | 0 | 1 based |
MarginLeft | float | Yes | NULL | in points |
MarginTop | float | Yes | NULL | |
MarginRight | float | Yes | NULL | |
MarginBottom | float | Yes | NULL | |
Active | int | Yes | NULL | 0 | 1 |
Name | varchar (512) | Yes | NULL | |
PageType | int | Yes | 0 | 0 : beliebig 1 : links 2 : rechts |
Barrier | int | Yes | NULL | 0 : Off 1: Left Page 2 : Right Page 3 : New Page |
OpositeID | int | Yes | NULL | ID of the opposite page, also see AutoOpposite |
SuccessorID | int | Yes | NULL | ID of the following page, also see AutoSuccessor |
Masterpages | varchar (4000) | Yes | NULL | Comma separated list of parent pages which may be applied |
AutoOposite | int | Yes | NULL | 0 | 1, Auto set opposite page (next document page) |
AutoSuccesor | int | Yes | NULL | 0 | 1, Auto set successor page (next document page) |
Templates | clob, longtext | Yes | NULL | XML-Text of the page templates |
Preview | blob, longblob | Yes | NULL | |
Data | blob, longblob | Yes | NULL | |
DocName | varchar (512) | Yes | '' |