Scripting Guide

PatternMaker adds a single property and a single method to the PageItem object. See the sample script that comes with BarcodeMaker to see how to script the plug-in. The following table gives more information.

Pattern and parameter names

The names of the patterns and parameters can be passed in as either the localized on non-localized strings. To find the non-localized string, do the following in InDesign desktop:

  • Create a barcode that you're interested in scripting
  • Drag and drop the barcode from InDesign to your desktop. This will create a snippet file on your desktop ending in .idms.
  • Open the snippet file in a text editor. You'll find the non-localized version of the pattern name and all the parameter names. They all will contain the text A9B001. Search for that text and you'll find the strings. The pattern name will be assigned to the Pattern attribute, and all the parameters will be assigned to the PatternParameters attribute. Here are some examples of pattern and parameter names for a UPC-A barcode:
  1. $ID/0xA9B001kUPCAPatternName - Pattern name to pass to assign to pattern property
  2. 0xA9B00kUPCAParamName - UPCA parameter name to pass to setPatternParam
  3. 0xA9B00kAlttextOptionName - Alt Text paramaeter name to pass to setPatternParam
  4. 0xA9B00kISBNSuffixParamName - Suffix parameter name to pass to setPatternParam

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:
setPatternParam

VBScript:
Set Pattern Param

AppleScript
set pattern param

page item

Event

Name

Type

Description

paramName

String, required

The name of the parameter to set

paramValue

String, required

The value of the parameter. “true” or “false” for boolean values, an integer for any measurements (always in points)

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:
pattern

VBScript:
Pattern

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:
patternParameters

VBScript:
Pattern Parameters

AppleScript:
pattern parameters

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:
setPreset

AppleScript
set preset

VBScript:
Set Preset

Page Item

Event

Name

Type

Description

preset name

String, optional

The name of the preset

Applies a preset to a page item..

JavaScript:
add

AppleScript
make

VBScript:
Add

Pattern preset collection on the document or workspace

Event

Name

Type

Description

preset name

String, optional

The name of the preset

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
remove

AppleScript:
delete

VBScript:
Delete

Pattern Preset

Event

This is an event with no parameters

Removes the preset from the collection in which it is contained.

JavaScript:
setPatternParam

VBScript:
Set Pattern Param

AppleScript
set pattern param

Pattern Preset

Event

Name

Type

Description

paramName

String, required

The name of the parameter to set

paramValue

String, required

The value of the parameter. “true” or “false” for boolean values, an integer for any measurements (always in points)

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
duplicate

VBScript
Duplicate

Pattern Preset

Event

Name

Type

Description

name

String, optional

What to name the duplicate. If omitted, will append the word “copy” to the existing preset name

Creates a duplicate of the preset

JavaScript:
patternParameters

VBScript:
Pattern Parameters

AppleScript:
pattern parameters

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:
pattern

VBScript:
Pattern

Pattern Preset

Property

The preset’s pattern

Setting this property will define what pattern is applied by the preset.

JavaScript and ApplieScript:
name

VBScript:
Name

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

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.