Pay once, no subscription. Free updates.|Try PowerScripts free|Install / update
PowerScripts Help

Site Tools


templator

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
templator [2018/03/10 02:13] – [Export Image] o2admintemplator [2026/10/25 02:53] (current) – Help pages updated for PowerScripts 3.8 (help pages session) remoteuser
Line 1: Line 1:
-Templator is a PowerScript to automatically open document templates, specifically for creating proof and approvals for customers.+====== Templator ====== 
 + 
 +Make proofs, approval forms and job folders in one click. Templator opens your template, brings in the selected artwork, fills in the job details (typed in, worked out from the document, or fetched from your job system), then saves the file, a PDF and a JPG where they belong. 
 + 
 +[[https://o2creative.co.nz/shop/Templator|See it in the shop]] · Version 2.2.3 · Needs PowerScripts 3.8.42 or later 
 + 
 +===== Where to find it ===== 
 + 
 +Open the PowerScripts panel (**Window > Extensions > PowerScripts**) and choose **Templator** from the **Tools** scripts. The script has three tabs: **Quick Create**, **Template Options** and **Help**. 
 + 
 +===== Quick start ===== 
 + 
 +  - On **Template Options**, under **Template**, choose your template file (for example your approval form). 
 +  - Under **Find and Replace**, set the codes to fill in, for example {date} and a {job} you type in. 
 +  - Under **Artwork**, choose to copy the selected artwork onto the template. 
 +  - Press **Apply Template**, and save the settings as a preset: it then shows on **Quick Create**, ready to double click next time. 
 + 
 +===== What it can do =====
  
 **Templator will** **Templator will**
Line 7: Line 24:
   * Copy the selected artwork in the current document and place it on the template, and rasterize it.   * Copy the selected artwork in the current document and place it on the template, and rasterize it.
   * Ask the user for custom information, such as job number, clients name, job title   * Ask the user for custom information, such as job number, clients name, job title
 +  * Run your own code to fetch extra data
   * Automatically replace text in the document such as date, name and any other text you want   * Automatically replace text in the document such as date, name and any other text you want
   * Connect to a URL to get information from a website or database, for example, enter in a job number and return the job name and customer details   * Connect to a URL to get information from a website or database, for example, enter in a job number and return the job name and customer details
Line 16: Line 34:
 **Typical uses** **Typical uses**
   * Create a job folder with sub-folders and save a blank working file.   * Create a job folder with sub-folders and save a blank working file.
-  * Copy the selected artwork and create an approval from on a new artboard+  * Copy the selected artwork and create an approval form on a new artboard 
 + 
 +===== Options =====
  
-====== Quick Create Tab ======+==== Quick Create ====
  
 {{:templator1.png|}} {{:templator1.png|}}
Line 24: Line 44:
 This tab lists the previously saved settings, double-click to load the template settings and create a template. This tab lists the previously saved settings, double-click to load the template settings and create a template.
  
-====== Template Options Tab ======+==== Template Options ====
  
 {{:templator2.png|}} {{:templator2.png|}}
Line 50: Line 70:
  
  
 +
 +----
 ==== Find and Replace ==== ==== Find and Replace ====
 Once the template is opened or embedded you can find and replace text in the template.  Once the template is opened or embedded you can find and replace text in the template. 
Line 57: Line 79:
   * **Type Column**   * **Type Column**
     * **Text** Replace with text in the //Default Text/Format// column     * **Text** Replace with text in the //Default Text/Format// column
-    * **Date** Replace with the current Date, See below for date formatting options+    * **Date** Replace with the current Date, See bottom of document for date formatting options \\ \\
     * **Document.name** Replace with document name     * **Document.name** Replace with document name
     * **Document.folder** Replace with document folder     * **Document.folder** Replace with document folder
     * **Document.filename** Replace with document filename     * **Document.filename** Replace with document filename
     * **Document.artboardCount** Replace with number of artboards in the document (excluding newly created template artboard)     * **Document.artboardCount** Replace with number of artboards in the document (excluding newly created template artboard)
-    * **Document.colorSpace** Replace with 'RGB' or 'CMYK' +    * **Document.colorSpace** Replace with 'RGB' or 'CMYK'  \\ \\ 
-    * **Artboard.width** //Default Text/Format// column formats the number, "units,decimals" i.e "inch,0" will be in inches with no decimal places "mm,2" will be milimeters with 2 decimal places +    * **Artboard.width** See Size formatting below 
-    * **Artboard.height** //Default Text/Format// column formats the number, "units,decimals" i.e "inch,0" will be in inches with no decimal places "mm,2" will be milimeters with 2 decimal places +    * **Artboard.height**See Size formatting below 
-    * **Artboard.number** the number of the artboard selected prior to creating the template+    * **Artboard.number** the number of the artboard selected prior to creating the template \\ \\ 
 +    * **Selection.width**  See Size formatting below 
 +    * **Selection.height** See Size formatting below 
 +    * **Selection.count** the number of selected items \\ \\
     * **User Text Input** Prompts the user for text     * **User Text Input** Prompts the user for text
       * //Default Text/Format// column contains the default text       * //Default Text/Format// column contains the default text
-      * //Input Validation// column contains rules for validate the input - see Validation below+      * //Validation// column contains rules for validating the input - see Validation below
       * //User Input Label// column contains the label for the form       * //User Input Label// column contains the label for the form
 +      * The text to find will ways be wrapped with {} brackets, so if your find text is "name" your document needs to contain "{name}" \\ \\
     * **User Number Input** Prompts the user for text     * **User Number Input** Prompts the user for text
       * //Default Text/Format// column contains the default text       * //Default Text/Format// column contains the default text
-      * //Input Validation// column contains rules for validate the input - see Validation below+      * //Validation// column contains rules for validating the input - see Validation below
       * //User Input Label// column contains the label for the form       * //User Input Label// column contains the label for the form
 +      *  The text to find will ways be wrapped with {} brackets, so if your find text is "num" your document needs to contain "{num}" \\ \\
     * **User Dropdown Input** Prompts the user for text     * **User Dropdown Input** Prompts the user for text
       * //Default Text/Format// column contains the default selected option, it must match an option in the input validation       * //Default Text/Format// column contains the default selected option, it must match an option in the input validation
-      * //Input Validation// column contains the list, Separate options by a vertical bar character. For example "one|two|three|four". If you require different return values prefix the name and separate with a tilde '~' symbol. For example "BS~Bob Smith|JD~John Doe|RB~Ruth Baker" will return 'BS','JD' or 'RB' not the full names+      * //Validation// column contains the list, with separate options by a vertical bar character. For example "one|two|three|four". If you require different return values prefix the name and separate with a tilde '~' symbol. For example "BS~Bob Smith|JD~John Doe|RB~Ruth Baker" will return 'BS','JD' or 'RB' not the full names
       * //User Input Label// column contains the label for the form       * //User Input Label// column contains the label for the form
 +      *  The text to find will ways be wrapped with {} brackets, so if your find text is "name" your document needs to contain "{name}" \\ \\
   * **Default Text/Format Column**     * **Default Text/Format Column**  
     * The default value for the form     * The default value for the form
Line 83: Line 111:
   * **Input Validation Column** See the User Input Validation Rules at the bottom of this page   * **Input Validation Column** See the User Input Validation Rules at the bottom of this page
   * **User Input Label Column** The label to show on the form if empty the find text will be used as a label   * **User Input Label Column** The label to show on the form if empty the find text will be used as a label
 +
 +----
 +
 +== Size formatting  ==
 +You can format the height, width and scale in the //Default Text/Format// column. 
 +
 +The formatting is  "units,decimals,scale" 
 +  * **units** Such as 'mm' 'in' 'pt', the full set of units are supported
 +  * **decimals** (Optional, default=2) The number of decimal points to display
 +  * **scale**  (Optional, default=1) The size is multiplied by the scale, so 1 is no change, 0.5 reduces the number by half, 20 makes the number twenty times larger.
 +
 +Examples
 +  * "inch,0" will be in inches with no decimal places 
 +  * "mm,2" will be millimetres with 2 decimal places
 +  * "mm,0,10" will be millimetres with no decimal places and ten times larger 
 +
 +
 +----
 +==== Scripting ====
 +
 +**Run script as**: **Do not run**, **ExtendScript in Illustrator**, or **Javascript in CEP/NodeJS**.
 +
 +
 +You can run Extendscript or Javascript to modify the document and return additional text changes to Templator. Your code will be wrapped in a function, so ensure that you include a return statement with the required data structure.
 +
 +Your code must return the standard object indicating success and any error messages/text changes, see the next section.
 +
 +**Warning: Make sure your code is self-contained and does not pollute the global scope**
 +
 +==ExtendScript in Illustrator==
 +  * Runs the code in Extendscript in Illustrator allowing you to modify and get information from the document. 
 +  * Note that ExtendScript and not modern ES6 Javascript and does not support the latest features of Javascript. see[[ https://ai-scripting.docsforadobe.dev/|Adobe scripting reference for details]].\\
 +
 +== Extendscript Example ==
 +<code javascript>
 +var d = new Date;
 +var success = false;
 +
 +data.textChanges.push({find: "{filename}", type: "activeDocument.name"});
 +data.textChanges.push({find: "*year*", type: "text", value: d.getFullYear()});
 +
 +if(success){
 +    return {
 +        success: true,
 +        data: data
 +    };
 +}
 +
 +return {
 +    success: true,
 +    errorMessage: 'No custom code setup'
 +};
 +</code>
 +
 +== Javascript in CEP/NodeJS ==
 +  * Runs the code in the CEP Panel of PowerScripts, this is modern Javascript running on NodeJS, see https://github.com/Adobe-CEP/CEP-Resources.    
 +  * Note that the following libraries are already loaded CSInterface, JQuery, Lodash, Moment.js, Numeral-js. 
 +  * You can run ExtendScript code using CSInterface.evalScript.
 +  * To asynchronously get data, return a Function, This function will be called with the first argument data and the second a callback
 +
 +== Javascript/Node Async Example ==
 +<code javascript>
 +return function getWebsite(data, callback){
 +     $.get("https://www.google.com",function(html){
 +         data.textChanges.push({find: "{html}", type: "text", value: html });
 +         callback({ success: true, data: data });
 +     });
 +}
 +</code>
 +
 +----
 ==== External Data ==== ==== External Data ====
-This gives you the option of retrieving data from an external source, such as a custom webpage linked to a database. +This gives you the option of retrieving data from an external source, such as a custom webpage linked to a database to Find and Replace text.
-  * **URL** contains the URL address, Note that this can contain find and replace characters, so, for example, you can use http://webserver/database.php?jobid={id} where {id} is a user input. This allows you to ask users for things like a job number, then use that in your URL.+
  
-The server must return data in the following JSON object\\ +  * **URL** contains the URL address, Note that this can contain find and replace characters, so, for example, you can use ''https://jobs.example.com/job.php?id={id}'' where {id} is from Javascript or user input. This allows you to ask users for things like a job number, then use that in your URL. 
-''  {''\\ + 
-''    success: ture|false,''\\ +The server must return data in the following JSON object, see below 
-''      errorMessage: string,''\\ + 
-''  data: { ''\\ +---- 
-''cat: "dog"''\\ +==== External URL and Javascript Return Data Format==== 
-''green: "blue"''\\ +The Javascript Extendscript must return the following, and the external webpage must return this in JSON. 
-''  }''\\+ 
 +<code javascript> 
 +{ 
 +    success: true|false, 
 +    errorMessage: string, 
 +    data: { 
 +         textChanges: [ 
 +              {find: "{animal}", type: "text", value: "Cat"} 
 +         ] 
 +    } 
 +} 
 +</code>
  
   * **success** is required. Boolean true or false   * **success** is required. Boolean true or false
   * **errorMessage** is optional. When success=false this message will be displayed.    * **errorMessage** is optional. When success=false this message will be displayed. 
-  * **data** is an object, with property-value pairs, The program will add curly brackets to the property name and replace that with the value. So in the example above "{cat}" will be replaced with "dog" and "{green}" will be replaced with "blue"+  * **data.textChanges** is an array of objects, {find: "textToFind", type: "text", value: "newText"}, Changes are made in reverse order  so you can bypass an existing replacement by pushing one oneto the end of the array. 
 +  * Replacement types:  
 +    * 'text' - Replace find text with value (if type is not included in the object text is assumed) 
 +    * 'date'  - Replace find text with today's date using the format defined in value  
 +    * 'template.name' 
 +    * 'document.folder' 
 +    * 'document.name' 
 +    * 'document.filename' 
 +    * 'document.rulerunits' 
 +    * 'document.colorspace' 
 +    * 'document.artboardcount' 
 +    * 'template.width': - value contains the units to use 
 +    * 'template.height': - value contains the units to use 
 +    * 'artboard.width': - value contains the units to use 
 +    * 'artboard.height' - value contains the units to use 
 +    * 'artboard.number' 
 + 
 + 
  
 +----
 ==== Artwork ==== ==== Artwork ====
 This option allows you to copy the currently selected artwork to the template and resize it. This has been designed for creating approval forms. This option allows you to copy the currently selected artwork to the template and resize it. This has been designed for creating approval forms.
Line 109: Line 237:
   * **Move X/Move Y** Allows you to move the artwork to an exact position on the artboard.   * **Move X/Move Y** Allows you to move the artwork to an exact position on the artboard.
  
 +
 +----
 ==== Folders ==== ==== Folders ====
  
   * **Create Folder** Enter the folder name to create, you can include find and replace variables in there too, such as [ C:\work\{client name}\Job J{jobNumber} ]. Leave blank to not create any folders    * **Create Folder** Enter the folder name to create, you can include find and replace variables in there too, such as [ C:\work\{client name}\Job J{jobNumber} ]. Leave blank to not create any folders 
   * **Sub Folders** Create multiple subfolders by separating folder names with a comma   * **Sub Folders** Create multiple subfolders by separating folder names with a comma
-  * **Open folder** Tick to open in OSX Finder or Windows Explorer after being created+  * **Open folder** Tick to open in macOS Finder or Windows Explorer after being created
  
 +
 +----
 ==== Save ==== ==== Save ====
 Saves the document as an Illustrator file Saves the document as an Illustrator file
Line 128: Line 260:
   * **Prompt for Filename** If unticked then the PowerScript will save without asking to confirm the filename   * **Prompt for Filename** If unticked then the PowerScript will save without asking to confirm the filename
  
 +
 +----
 ==== Export PDF ==== ==== Export PDF ====
 Exports the document as an Illustrator file Exports the document as an Illustrator file
Line 148: Line 282:
  
  
 +
 +----
 ==== Export Image ==== ==== Export Image ====
 Exports the Template Artboard as an Image Exports the Template Artboard as an Image
Line 165: Line 301:
   * **Transparent PNG/PSD** Enable transparency in PNG and PSD files   * **Transparent PNG/PSD** Enable transparency in PNG and PSD files
  
-====== Date Formats ======+==== Post ExtendScript ==== 
 + 
 +  * **Execute ExtendScript after all other actions completed**: run your ExtendScript code (from **Scripting**) once everything else is done: the template is in, the text replaced and the files saved. 
 + 
 +  * **Apply Template**: does it. 
 + 
 +===== Date formats =====
  
 ^ Mask      ^ Description         ^ ^ Mask      ^ Description         ^
Line 201: Line 343:
  
  
-====== Unit Formats  ======+===== Unit formats =====
 ^ Abbreviation ^ Singular ^ Plural ^ note ^ ^ Abbreviation ^ Singular ^ Plural ^ note ^
 | ft | foot | feet |  | ft | foot | feet | 
Line 217: Line 359:
  
  
-====== User Text Input Validation ======+===== User text input validation =====
  
  
Line 237: Line 379:
  
  
-===== Release Notes ===== +===== What's new =====
- +
-==== Version 1.3.0 ==== +
-  * Added: Support for PNG, TIFF and PSD (Photoshop) image exports +
-  * Added: Support for transparent image export +
-  * Added: Ability to choose "Do not import any templates" so you can use this PowerScript to only Replace Text/Save/Export PDF/Export Image. Ideal for a 3 step process: i.e Step 1 create a template, Step 2 Edit template then Step 3 Save/Export PDF/Export Image +
-  * Added: Checkbox for find and Replace to turn this feature off +
-  * Minor Fixes +
  
 +  * **2.2.3**
 +    * Improved: new documents use 300 ppi raster effects (shadows, blurs, rasterizing), the print setting.
 +    * Fixed: {Artboard.number} and the PDF range Current artboard use the right artboard when the template is a new document.
 +    * Improved: safer when working with more than one document. Needs PowerScripts 3.8.42 or later.
 +  * **2.2.2**
 +    * Improved: Copy Selected Artwork no longer uses copy and paste, so your clipboard is left alone.
 +    * Fixed: Copy Selected Artwork works into a new template document and with No Action, and no longer crashes Illustrator.
 +    * Fixed: running from a hot key, quick key or automation works, Execute ExtendScript after all other actions runs your code again, and the regex: and wordafter: formats work.
 +    * Improved: general bug fixes, reliability and speed.
 +  * **2.2.0**: Copying a template from another file is more reliable (no more copy and paste, so your clipboard is left alone).
 +  * Older changes: [[releasenotes|PowerScripts Release Notes]]
  
templator.1520648014.txt.gz · Last modified: by o2admin