Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
templator [2018/03/10 02:13] – [Export Image] o2admin | templator [2024/04/03 07:16] (current) – [Javascript] o2admin | ||
---|---|---|---|
Line 7: | Line 7: | ||
* 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, | * Ask the user for custom information, | ||
+ | * **(NEW) Run Javascript to fetch additional 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 50: | Line 51: | ||
+ | |||
+ | ---- | ||
==== 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 60: | ||
* **Type Column** | * **Type Column** | ||
* **Text** Replace with text in the //Default Text/ | * **Text** Replace with text in the //Default Text/ | ||
- | * **Date** Replace with the current Date, See below for date formatting options | + | * **Date** Replace with the current Date, See bottom of document |
* **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 ' | + | * **Document.colorSpace** Replace with ' |
- | * **Artboard.width** | + | * **Artboard.width** |
- | * **Artboard.height** | + | * **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** | ||
+ | * **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/ | * //Default Text/ | ||
Line 83: | Line 89: | ||
* **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/ | ||
+ | |||
+ | The formatting is " | ||
+ | * **units** Such as ' | ||
+ | * **decimals** (Optional, default=2) The number of decimal points to display | ||
+ | * **scale** | ||
+ | |||
+ | Examples | ||
+ | * " | ||
+ | * " | ||
+ | * " | ||
+ | |||
+ | |||
+ | ---- | ||
+ | ==== Javascript ==== | ||
+ | |||
+ | 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/ | ||
+ | |||
+ | **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:// | ||
+ | |||
+ | == Extendscript Example == | ||
+ | <sxh javascript; > | ||
+ | var d = new Date; | ||
+ | var success = false; | ||
+ | |||
+ | data.textChanges.push({find: | ||
+ | data.textChanges.push({find: | ||
+ | |||
+ | if(success){ | ||
+ | return { | ||
+ | success: true, | ||
+ | data: data | ||
+ | }; | ||
+ | } | ||
+ | |||
+ | return { | ||
+ | success: true, | ||
+ | errorMessage: | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | == Javascript in CEP/NodeJS == | ||
+ | * Runs the code in the CEP Panel of PowerScripts, | ||
+ | * Note that the following libraries are already loaded CSInterface, | ||
+ | * 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/ | ||
+ | <sxh javascript; > | ||
+ | return function getWebsite(data, | ||
+ | | ||
+ | | ||
+ | | ||
+ | }); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ---- | ||
==== 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:// | + | |
- | 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 **http:// |
- | '' | + | |
- | '' | + | The server must return data in the following JSON object, see below |
- | '' | + | |
- | '' | + | ---- |
- | '' | + | ==== External URL and Javascript Return Data Format==== |
- | '' | + | The Javascript Extendscript must return the following, and the external webpage must return this in JSON. |
- | '' | + | |
+ | <sxh javascript; > | ||
+ | { | ||
+ | success: | ||
+ | errorMessage: | ||
+ | data: { | ||
+ | textChanges: | ||
+ | {find: "{{animal}}": type: "text", value: " | ||
+ | ] | ||
+ | | ||
+ | </ | ||
* **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 " | + | * **data.textChanges** is an array of objects, {find: " |
+ | * Replacement types: | ||
+ | * ' | ||
+ | * ' | ||
+ | * ' | ||
+ | * ' | ||
+ | * ' | ||
+ | * ' | ||
+ | * ' | ||
+ | * ' | ||
+ | * ' | ||
+ | * ' | ||
+ | * ' | ||
+ | * ' | ||
+ | * ' | ||
+ | * ' | ||
+ | |||
+ | |||
+ | ---- | ||
==== 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 211: | ||
* **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 ==== | ||
Line 115: | Line 219: | ||
* **Open folder** Tick to open in OSX Finder or Windows Explorer after being created | * **Open folder** Tick to open in OSX 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 234: | ||
* **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 256: | ||
+ | |||
+ | ---- | ||
==== Export Image ==== | ==== Export Image ==== | ||
Exports the Template Artboard as an Image | Exports the Template Artboard as an Image | ||
Line 238: | Line 348: | ||
===== Release Notes ===== | ===== Release Notes ===== | ||
+ | |||
+ | ==== Version 2.0.0 ==== | ||
+ | * Added preview images and abibility to generate previews | ||
+ | * Added in more data types, selection.width, | ||
+ | * Added in Scale for measurements | ||
+ | * Added in Javascript and Extendscript support | ||
==== Version 1.3.0 ==== | ==== Version 1.3.0 ==== |