PatternMaker adds one property and one method to the InDesign PageItem object. You can use these to apply barcode patterns and set barcode parameters from JavaScript, AppleScript, or VBScript.
For working examples, see the sample scripts installed with BarcodeMaker:
PatternMakerParamsDemoScript.jsxPatternMakerPresetDemoScript.jsx
Pattern and Parameter Names
Pattern and parameter names can be passed as either localized or non-localized strings. For scripts that need to work reliably across localized versions of InDesign, use the non-localized names.
To find the non-localized names:
- In InDesign, create the barcode you want to script.
- Drag the barcode from InDesign to your desktop. This creates an
.idmssnippet file. - Open the
.idmsfile in a text editor. - Search for
A9B001. - Look for:
- The pattern name assigned to the
Patternattribute. - The parameter names assigned to the
PatternParametersattribute.
- The pattern name assigned to the
For example, a UPC-A barcode may include names like these:
| Non-localized name | Purpose |
|---|---|
$ID/0xA9B001kUPCAPatternName | Pattern name to assign to the pattern property |
0xA9B00kUPCAParamName | UPC-A parameter name to pass to setPatternParam |
0xA9B00kAlttextOptionName | Alt text parameter name to pass to setPatternParam |
0xA9B00kISBNSuffixParamName | Suffix parameter name to pass to setPatternParam |
Performance Tip
When creating many barcodes from a template, use a preset instead of setting every parameter individually.
A faster workflow is:
- Create a preset.
- Configure all static preset parameters once.
- For each barcode, modify only the data parameter on the preset.
- Apply the preset to the InDesign frame.
This avoids repeatedly setting unchanged parameters and is much faster for batch barcode generation.
PatternMaker methods
These events and properties all exist on page items. You can set a pattern by its name, and you can pattern parameters or individual properties. See the demo JavaScript that installs with the plug-in to see these events and properties in action. The script is called “PatternMakerParamsDemoScript.jsx”.
Name | Parent | Type | Parameters | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
JavaScript: VBScript: AppleScript | page item | Event |
| Sets the paramater of a pattern. For example, for an ISBN barcode, parameters include “ISBN”, “Top font”, “Include text”, etc. Type the name of the parameter exactly as it appears in the PatternMaker palette. | |||||||||
JavaScript and AppleScript: VBScript: | page item | Property | This is a String property.. | Set this property equal to the pattern name to apply a pattern. The pattern name should be exactly as it appears in the PatternMaker dropdown list of patterns. | |||||||||
JavaScript: VBScript: AppleScript: | page item | Property | This is a string property describing all parameters in a given parameter in a single string of name value pairs. Each pair is separated by a tilde (~) and names and values are separated by a colon (:). So a typical pattern’s parameters might look like this: EAN-2:10~Include text:true~Font:Verdana~Font style:Regular~Font size:10~Font position:0~Barcode Height:1~Ink Spread:0.15 | Setting this property will set all parameters at once. it is much faster to use this property than to set parameters one at a time with SetPatternParam. |
Pattern Preset methods
The following preset methods operate on pattern presets, which can be found in a collection on either the document or the application. See the demo JavaScript that installs with the plug-in to see these events and properties in action. The script is called “PatternMakerPresetDemoScript.jsx”.
Name | parent | Type | Parameters | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
JavaScript: AppleScript VBScript: | Page Item | Event |
| Applies a preset to a page item.. | |||||||||
JavaScript: AppleScript VBScript: | Pattern preset collection on the document or workspace | Event |
| Adds a new preset. The pattern for the preset will default to the first pattern available. You should make sure to set the pattern property on the preset immediately after creating the preset.. | |||||||||
JavaScript AppleScript: VBScript: | Pattern Preset | Event | This is an event with no parameters | Removes the preset from the collection in which it is contained. | |||||||||
JavaScript: VBScript: AppleScript | Pattern Preset | Event |
| Sets the paramater of a pattern. For example, for an ISBN barcode, parameters include “ISBN”, “Top font”, “Include text”, etc. Type the name of the parameter exactly as it appears in the PatternMaker palette. | |||||||||
JavaScript and AppleScriptt VBScript | Pattern Preset | Event |
| Creates a duplicate of the preset | |||||||||
JavaScript: VBScript: AppleScript: | Pattern Preset | Property | This is a string property describing all parameters in a given parameter in a single string of name value pairs. Each pair is separated by a tilde (~) and names and values are separated by a colon (:). So a typical pattern’s parameters might look like this: EAN-2:10~Include text:true~Font:Verdana~Font style:Regular~Font size:10~Font position:0~Barcode Height:1~Ink Spread:0.15 | Setting this property will set all parameters at once. it is much faster to use this property than to set parameters one at a time with SetPatternParam. | |||||||||
JavaScript and ApplieScript: VBScript: | Pattern Preset | Property | The preset’s pattern | Setting this property will define what pattern is applied by the preset. | |||||||||
JavaScript and ApplieScript: VBScript: | Pattern Preset | Property | The preset’s name | This is the name of the preset, that appears in the presets dropdown in the PatternMaker palette and in the Edit Presets dialog |