About Arbortext Styler > Advanced Formatting Techniques > Generating Barcodes and QR Codes
  
Generating Barcodes and QR Codes
PTC Arbortext Layout Developer supports barcodes and other scannable objects, for example QR codes. You can use PTC ALD edited source in your Arbortext Styler stylesheet to configure a graphic object to display a code of the required type, with the requisite value. The code can then be included in PDF output generated by the PTC ALD engine.
Refer to Logic for Print/Preview Engine Selection for information on how to set the print engine for your environment.
PTC ALD includes a full library of code types that conform to recognized standards, for example:.
Barcodes — CODE 128, EAN-8, EAN-13, EAN-2, EAN-5, DUN-14, Code 25, Code 39, Code 93, GS1-128, ITF-14, Pharmacode, and JAN standards
QR codes — ISO/IEC 18004 standard
Sample code to create a new barcode is given below:
//Create the barcode object. This is just a normal barcode
var b = new fBarcode;
b.type = fBarcode.BARCODE_EANX;

//Create a variable for the value to use when creating the barcode
var value = "981858705125";
//Create a variable for the tag to create based on the value to
ensure the graphic is unique to the value
var tagName = "barcode_" + application.calculateHash(value);

//Create the barcode graphic, unless it already exists
var barcodeGraphic = template.content.getGraphic(tagName);
if (!barcodeGraphic) {
barcodeGraphic = template.content.createBarcode(tagName,"80mm",
"30mm","black","none",b,value);
}

//Output the barcode graphic inline
formatting.addImage(barcodeGraphic);
The first section of code includes the line b.type = fBarcode.BARCODE_EANX;, which specifies that a barcode of type EAN will be generated. See Barcode Types and Options below for a list of supported barcode types. Note that the value declared in the second section of code, 981858705125, is 12 digits long. The code will generate an EAN-13 barcode.
Refer to fBarcode for further information.
The second section of the code defines the value that will be displayed in the barcode, i.e. 981858705125. It also includes barcode_" + application.calculateHash(value) to generate the name of the graphic tag that will be created to display the barcode. Here the tag name will be barcode_981858705125 — the text barcode_ followed by the current value of the variable value.
The third section of code uses the fContent.createBarcode() method to output the barcode (a graphic) with certain properties:
tagName — the name of the graphic tag
In this example, the current value of the variable tagName will be queried for the tag name
“80mm” — width
“30mm” — height
“black” — foreground color of barcode (for bars and numbers etc.)
“none” — background color of barcode
b — barcode type
In this example, the current value of the variable b will be queried for the barcode information
value — value (numbers)
In this example, the current value of the variable value will be queried for the value
The method will fail if the tag already exists.
Refer to the description of the fContent.generateBarcode() method for further information.
A sample file that demonstrates PTC ALD’s barcode capability and options is provided at Arbortext-path\samples\APP\Barcode. You can refer to these files:
barcodeSampler.xml — sample XML file with elements configured to output each one of PTC ALD’s available barcode types. The sample also describes the property sets provided in the accompanying stylesheet.
barcodeSample.style — stylesheet with property sets that provide the PTC ALD source edits required to generate the barcodes.
Barcode Types and Options
Supported barcode types are listed below. When declaring for an fBarcode object, you can specify the type with either the constant name or the number.
One-dimensional Barcodes
Barcode Type
Constant Name
Number
Code 11
fBarcode.BARCODE_CODE11
1
Value can take a string of digits of any length and an optional hyphen
Codabar
fBarcode.BARCODE_CODABAR
18
Value can be any length and can consist of one letter (A-D), followed by a combination of numbers, dash, colon, slash, full-stops or plus signs, followed by another letter (A-D)
Pharmacode One-Track
fBarcode.BARCODE_PHARMA
51
Value must be a number between 3 and 131070
Korea Post
fBarcode.BARCODE_KOREAPOST
77
Value is a 6 digit numeric string
Channel Code
fBarcode.BARCODE_CHANNEL
140
Value is a numeric string up to 7 digits long.
This barcode type can accept an fBarcode.option2 property to specify the number of digits the library should expect (the channels):
fBarcode.option2=3 — a two digit value between 00 and 26
fBarcode.option2=4 — a three digit value between 000 and 292
fBarcode.option2=5 — a four digit value between 0000 and 3493
fBarcode.option2=6 — a five digit value between 00000 and 44072
fBarcode.option2=7 — a six digit value between 000000 and 576688
fBarcode.option2=8 — a seven digit value between 0000000 and 7742862
If fewer digits are supplied, leading 0s will be added. If too many digits are provided, or the value is out of the specified range, no barcode will be generated and an error will be raised.
Code 2 of 5 Variants
Standard Code 2 of 5
fBarcode.BARCODE_C25MATRIX
2
Value takes a string of numbers of any length
Interleaved 2 of 5
fBarcode.BARCODE_C25INTER
3
Value can take a string of numbers of any length, ideally an even number of numbers
If an odd number is provided, a leading 0 will be added.
Code 2 of 5 IATA
fBarcode.BARCODE_C25IATA
4
Value can take a numeric string of any length
Code 2 of 5 Data Logic
fBarcode.BARCODE_C25LOGIC
6
Value can take a string of numbers of any length
Code 2 of 5 Industrial
fBarcode.BARCODE_C25IND
7
Value can take a string of numbers of any length
ITF-14
fBarcode.BARCODE_ITF14
89
Value takes a 13 digit numeric string
Deutsche Post Leitcode
fBarcode.BARCODE_DPLEIT
21
Value takes a 13 digit numeric string
Deutsche Post Identcode
fBarcode.BARCODE_DPIDENT
22
Value takes an 11 digit numeric string
UPC Variants
UPC A
fBarcode.BARCODE_UPCA
34
Value takes an 11 digit numeric string
EAN-2 and EAN-5 add-ons can be added by following the value with a + and the appropriate number of digits.
UPC E
fBarcode.BARCODE_UPCE
37
Value takes a 6 digit numeric string.
EAN2 and EAN5 add-ons can be added by following the value with a + and the appropriate number of digits.
EAN Variants
EAN
fBarcode.BARCODE_EANX
13
This barcode type will create the appropriate barcode depending on the number of digits provided:
EAN-2 is generated from 2 digits
EAN-5 is generated from 5 digits
EAN-8 is generated from 7 digits
EAN-13 is generated from 12 digits
Add-on barcodes can be created by providing a value with two sets of digits separated by a + symbol.
ISBN (EAN-13 with verification stage)
fBarcode.BARCODE_ISBNX
69
Value can be 9, 10, or 13 digits long
If the code is invalid an error will be raised.
Plessey Variants
Plessey Code
fBarcode.BARCODE_PLESSEY
86
Value can be any length and can include digits and the letters A-E
MSI Plessey
fBarcode.BARCODE_MSI_PLESSEY
47
Value can take a numeric string of any length
This type can accept an fBarcode.option2 property to control the check digits generated by the library:
fBarcode.option2 = 0 — no check digit
fBarcode.option2 = 1 — a modulo 10 check digit
fBarcode.option2 = 2 — two modulo 10 check digits
fBarcode.option2 = 3 — a modulo 11 check digit
fBarcode.option2 = 4 — a modulo 11 check digit and a modulo 10 check digit
Telepen Variants
Telepen Alpha
fBarcode.BARCODE_TELEPEN
32
Value can take an ASCII string of any length
Telepen Numeric
fBarcode.BARCODE_TELEPEN_NUM
87
Value takes a numeric string of an even number length
Code 39 Variants
Code 3 of 9 (Code 39)
fBarcode.BARCODE_CODE39
8
Value can take a string of numbers, letters, dash, full stop, space, dollar, slash and percent symbols of any length
Adding an optional fBarcode.option2=1 generates the check digit.
Extended Code 3 of 9 (Code 39+)
fBarcode.BARCODE_EXCODE39
9
Value can be a string of ASCII characters of any length.
Adding an optional fBarcode.option2=1 generates the check digit.
Code 93
fBarcode.BARCODE_CODE93
25
Value can take a string of ASCII characters of any length
PZN
fBarcode.BARCODE_PZN
52
Value takes a 6 digit numeric string
LOGMARS
fBarcode.BARCODE_LOGMARS
50
Value takes the same type of string as the standard code 39
Code 32
fBarcode.BARCODE_CODE32
129
Value takes a numeric string up to 8 characters long
HIBC Code 39
fBarcode.BARCODE_HIBC_39
99
Value takes the same type of string as code 39
Code 128 Variants
Code 128 (automatic subset switching)
fBarcode.BARCODE_CODE128
20
Value takes a string starting with an Application Identifier in square brackets
Errors will be raised if the Application Identifier is missing or if an incorrect string length for the Application Identifier is provided.
Code 128 (Subset B)
fBarcode.BARCODE_CODE128B
60
As above, but without automatic switching to Code C
GS1-128
fBarcode.BARCODE_EAN128
16
Value takes a string starting with an Application Identifier in square brackets
Errors will be raised if the Application Identifier is missing or if an incorrect string length for the Application Identifier is provided.
EAN-14
fBarcode.BARCODE_EAN14
72
Value takes a 13 digit numeric string
If fewer than 13 digits are provided, leading 0s will be added.
NVE-18
fBarcode.BARCODE_NVE18
75
Value takes a 17 digit numeric string
If fewer than 17 digits are provided, leading 0s will be added.
HIBC Code 128
fBarcode.BARCODE_HIBC_128
98
Takes the same input for value as the standard Code 128
The leading + and trailing check digit are generated.
GS1 DataBar Variants
GS1 DataBar-14
fBarcode.BARCODE_RSS14
29
Value can be a numeric string up to 13 digits long
If fewer than 13 digits are provided, leading 0s will be added.
GS1 DataBar Limited
fBarcode.BARCODE_RSS_LTD
30
Value can be a numeric string up to 13 digits long, which must start with a 1 or a 0
GS1 DataBar Expanded
fBarcode.BARCODE_RSS_EXP
31
Value takes a numeric string with Application Identifiers in square brackets
No barcode will be generated if the number of digits in the string is not appropriate for the Application Identifier.
Stacked Symbols
Barcode Type
Constant Name
Number
Code 16K
fBarcode.BARCODE_CODE16K
23
Value is one or more groups of ASCII characters, separated by a comma
PDF417
fBarcode.BARCODE_PDF417
55
Value can be an ASCII string up to 1850 text characters or 2710 digits long
The value can accept options:
fBarcode.option1 — specifies the checksum codewords
Enter a value between 0 and 8.
fBarcode.option2 — specifies the number of column width of the generated symbol
Enter a value between 1 and 30.
HIBC PDF417
fBarcode.BARCODE_HIBC_PDF
106
As above
PDF417 Truncated
fBarcode.BARCODE_PDF417TRUNC
56
Options are the same as for PDF417
MicroPDF417
fBarcode.BARCODE_MICROPDF417
84
Value is similar to PDF417, but the value is limited to 250 characters (or 366 digits)
Use the fBarcode.option2 property to specify the number of columns (1–4).
HIBC MicroPDF417
fBarcode.BARCODE_HIBC_MICPDF
108
As above.
GS1 DataBar-14 Stacked
fBarcode.BARCODE_RSS14STACK
79
Value can be a numeric string up to 12 digits long
If fewer than 12 digits are provided, leading 0s will be added.
GS1 DataBar-14 Stacked Omnidirectional
fBarcode.BARCODE_RSS14STACK_OMNI
80
Value can be a numeric string up to 12 digits long
If fewer than 12 digits are provided, leading 0s will be added.
GS1 DataBar Expanded Stacked
fBarcode.BARCODE_RSS_EXPSTACK
81
Value takes a numeric string
fBarcode.option2 can provide the width (number of columns) for the generated symbol.
This type will generate a stacked symbol if multiple codes are provided with their Application Identifiers (e.g. value = [01]12345678901234[01]12345678901234).
Code 49
fBarcode.BARCODE_CODE49
24
Two-track Symbols
Barcode Type
Constant Name
Number
Pharmacode Two-Track
fBarcode.BARCODE_PHARMA_TWO
53
Value can be a numeric string with a value between 4 and 64570080
PostNet
fBarcode.BARCODE_POSTNET
40
Value can be a numeric string of any length
PLANET
fBarcode.BARCODE_PLANET
82
Value can be a numeric string of any length
4–State Postal Codes
Barcode Type
Constant Name
Number
AUSTRALIAN
Australia Post Standard Customer
fBarcode.BARCODE_AUSPOST
63
Value should follow one of the following patterns:
12345678 — will output a 37 bar symbol, where the value is an 8 digit numeric string
12345678ABCDE — will output a 52 bar symbol, where the value is a 13 character string of 8 digits followed by 5 alphabetical characters
1234567812345678 — will also output a 52 bar symbol, where the value is a 16 digit numeric string
12345678ABCDEFGHIJ — will output a 67 bar symbol, where the value is an 8 digit numeric string followed by a 10 character alphabetical string
12345678901234567890123 — will output a 67 bar symbol, where the value is a 23 digit numeric string
Australia Post Reply Paid
fBarcode.BARCODE_AUSREPLY
66
Value takes an 8 digit numeric string
Australia Post Routing
fBarcode.BARCODE_AUSROUTE
67
Value takes an 8 digit numeric string
Australia Post Redirection
fBarcode.BARCODE_AUSREDIRECT
68
Value takes an 8 digit numeric string
DUTCH
Dutch Post KIX Code
fBarcode.BARCODE_KIX
90
The value can have numbers and alphabetical characters (A-Z)
ROYAL MAIL
Royal Mail 4 State (RM4SCC)
fBarcode.BARCODE_RM4SCC
70
Value can be a string of letters and numbers
USPS
USPS OneCode
fBarcode.BARCODE_ONECODE
85
Value must be at least 20 digits long
After 20 digits, the value takes a dash followed by either 0, 5, 9, or 11 further digits.
Errors will be raised if this pattern is not followed.
JAPANESE
Japanese Postal Code
fBarcode.BARCODE_JAPANPOST
76
Value can accept numbers, alphabetical characters (A-Z), and dashes
Two-dimensional Symbols
Barcode Type
Constant Name
Number
Data Matrix
fBarcode.BARCODE_DATAMATRIX
71
Value can be any ASCII + Latin–1 text
The value can accept a fBarcode.option2 property to determine the size of the symbol generated:
fBarcode.option2 = 1 — a 10x10 symbol
fBarcode.option2 = 2 — a 12x12 symbol
fBarcode.option2 = 3 — a 14x14 symbol
fBarcode.option2 = 4 — a 16x16 symbol
fBarcode.option2 = 5 — a 18x18 symbol
fBarcode.option2 = 6 — a 20x20 symbol
fBarcode.option2 = 7 — a 22x22 symbol
fBarcode.option2 = 8 — a 24x24 symbol
fBarcode.option2 = 9 — a 26x26 symbol
fBarcode.option2 = 10 — a 32x32 symbol
fBarcode.option2 = 11 — a 36x36 symbol
fBarcode.option2 = 12 — a 40x40 symbol
fBarcode.option2 = 13 — a 44x44 symbol
fBarcode.option2 = 14 — a 48x48 symbol
fBarcode.option2 = 15 — a 52x52 symbol
fBarcode.option2 = 16 — a 64x64 symbol
fBarcode.option2 = 17 — a 72x72 symbol
fBarcode.option2 = 18 — a 80x80 symbol
fBarcode.option2 = 19 — a 88x88 symbol
fBarcode.option2 = 20 — a 96x96 symbol
fBarcode.option2 = 21 — a 104x104 symbol
fBarcode.option2 = 22 — a 120x120 symbol
fBarcode.option2 = 23 — a 132x132 symbol
fBarcode.option2 = 24 — a 144x144 symbol
fBarcode.option2 = 25 — a 8x18 symbol
fBarcode.option2 = 26 — a 8x32 symbol
fBarcode.option2 = 27 — a 12x26 symbol
fBarcode.option2 = 28 — a 12x36 symbol
fBarcode.option2 = 29 — a 16x36 symbol
fBarcode.option2 = 30 — a 16x48 symbol
HIBC Data Matrix
fBarcode.BARCODE_HIBC_DM
102
As above
QR Code
fBarcode.BARCODE_QRCODE
58
Value can be up to 7089 digits or 4296 alphanumeric characters from ASCII plus Latin-1 and kanji characters
QR codes can take two options:
fBarcode.option1 specifies the level or error correction encoded in the symbols:
fBarcode.option1 = 1 — ECC level L
fBarcode.option1 = 2 — ECC level M
fBarcode.option1 = 3 — ECC level Q
fBarcode.option1 = 4 — ECC level H
fBarcode.option2 determines the size of the symbol generated:
fBarcode.option2 = 1 — a 21 x 21 QR code
fBarcode.option2 = 2 — a 25 x 25 QR code
fBarcode.option2 = 3 — a 29 x 29 QR code
fBarcode.option2 = 4 — a 33 x 33 QR code
fBarcode.option2 = 5 — a 37 x 37 QR code
fBarcode.option2 = 6 — a 41 x 41 QR code
fBarcode.option2 = 7 — a 45 x 45 QR code
fBarcode.option2 = 8 — a 49 x 49 QR code
fBarcode.option2 = 9 — a 53 x 53 QR code
fBarcode.option2 = 10 — a 57 x 57 QR code
fBarcode.option2 = 11 — a 61 x 61 QR code
fBarcode.option2 = 12 — a 65 x 65 QR code
fBarcode.option2 = 13 — a 69 x 69 QR code
fBarcode.option2 = 14 — a 73 x 73 QR code
fBarcode.option2 = 15 — a 77 x 77 QR code
fBarcode.option2 = 16 — a 81 x 81 QR code
fBarcode.option2 = 17 — a 85 x 85 QR code
fBarcode.option2 = 18 — a 89 x 89 QR code
fBarcode.option2 = 19 — a 93 x 93 QR code
fBarcode.option2 = 20 — a 97 x 97 QR code
fBarcode.option2 = 21 — a 101 x 101 QR code
fBarcode.option2 = 22 — a 105 x 105 QR code
fBarcode.option2 = 23 — a 109 x 109 QR code
fBarcode.option2 = 24 — 113 x 113 QR code
fBarcode.option2 = 25 — a 117 x 117 QR code
fBarcode.option2 = 26 — a 121 x 121 QR code
fBarcode.option2 = 27 — a 125 x 125 QR code
fBarcode.option2 = 28 — a 129 x 129 QR code
fBarcode.option2 = 29 — a 133 x 133 QR code
fBarcode.option2 = 30 — a 137 x 137 QR code
fBarcode.option2 = 31 — a 141 x 141 QR code
fBarcode.option2 = 32 — a 145 x 145 QR code
fBarcode.option2 = 33 — a 149 x 149 QR code
fBarcode.option2 = 34 — a 153 x 153 QR code
fBarcode.option2 = 35 — a 157 x 157 QR code
fBarcode.option2 = 36 — a 161 x 161 QR code
fBarcode.option2 = 37 — a 165 x 165 QR code
fBarcode.option2 = 38 — a 169 x 169 QR code
fBarcode.option2 = 39 — a 173 x 173 QR code
fBarcode.option2 = 40 — a 177 x 177 QR code
HIBC QR Code
fBarcode.BARCODE_HIBC_QR
104
As above
Micro QR Code
fBarcode.BARCODE_MICROQR
97
Value can be Latin-1 and kanji characters
The value can accept a fBarcode.option2 property to specify the version of the code to be used:
fBarcode.option2 = 1 — uses version M1 of the code, which generates an 11x11 symbol
fBarcode.option2 = 2 — uses version M2 of the code, which generates a 13x13 symbol
fBarcode.option2 = 3 — uses version M3 of the code, which generates a 15x15 symbol
fBarcode.option2 = 4 — uses version M4 of the code, which generates a 17x17 symbol
Aztec Code
fBarcode.BARCODE_AZTEC
92
Value can be any ASCII string up to 3067 alphanumeric characters or 3823 digits long
This type can accept two options:
fBarcode.option1 sets the error correction capacity:
fBarcode.option1 = 1 — >10% + 3 codewords
fBarcode.option1 = 2 — >23% + 3 codewords
fBarcode.option1 = 3 — >36% + 3 codewords
fBarcode.option1 = 4 — >50% + 3 codewords
fBarcode.option2 sets the size of the symbol produced:
fBarcode.option2 = 1 — 15 x 15 symbol
fBarcode.option2 = 2 — 19 x 19 symbol
fBarcode.option2 = 3 — 23 x 23 symbol
fBarcode.option2 = 4 — 27 x 27 symbol
fBarcode.option2 = 5 — 19 x 19 symbol
fBarcode.option2 = 6 — 23 x 23 symbol
fBarcode.option2 = 7 — 27 x 27 symbol
fBarcode.option2 = 8 — 31 x 31 symbol
fBarcode.option2 = 9 — 37 x 37 symbol
fBarcode.option2 = 10 — 41 x 41 symbol
fBarcode.option2 = 11 — 45 x 45 symbol
fBarcode.option2 = 12 — 49 x 49 symbol
fBarcode.option2 = 13 — 53 x 53 symbol
fBarcode.option2 = 14 — 57 x 57 symbol
fBarcode.option2 = 15 — 61 x 61 symbol
fBarcode.option2 = 16 — 67 x 67 symbol
fBarcode.option2 = 17 — 71 x 71 symbol
fBarcode.option2 = 18 — 75 x 75 symbol
fBarcode.option2 = 19 — 79 x 79 symbol
fBarcode.option2 = 20 — 83 x 83 symbol
fBarcode.option2 = 21 — 87 x 87 symbol
fBarcode.option2 = 22 — 91 x 91 symbol
fBarcode.option2 = 23 — 95 x 95 symbol
fBarcode.option2 = 24 — 101 x 101 symbol
fBarcode.option2 = 25 — 105 x 105 symbol
fBarcode.option2 = 26 — 109 x 109 symbol
fBarcode.option2 = 27 — 113 x 113 symbol
fBarcode.option2 = 28 — 117 x 117 symbol
fBarcode.option2 = 29 — 121 x 121 symbol
fBarcode.option2 = 30 — 125 x 125 symbol
fBarcode.option2 = 31 — 131 x 131 symbol
fBarcode.option2 = 32 — 135 x 135 symbol
fBarcode.option2 = 33 — 139 x 139 symbol
fBarcode.option2 = 34 — 143 x 143 symbol
fBarcode.option2 = 35 — 147 x 147 symbol
fBarcode.option2 = 36 — 151 x 151 symbol
If both options are set, option1 will be ignored.
HIBC Aztec Code
fBarcode.BARCODE_HIBC_AZTEC
112
As above
Aztec Runes
fBarcode.BARCODE_AZRUNE
128
Value can be any integer between 0 and 255
Code One
fBarcode.BARCODE_CODEONE
141
Value can be Latin-1 or ASCII characters
The amount of content provided by the value is specified by the type, which is controlled by the value of the fBarcode.option2 property:
Value of property
Version of Code One
Size
Numeric string size
Alphanumeric string size
1
A
16 x 18
22
13
2
B
22 x 22
44
27
3
C
28 x 32
104
64
4
D
40 x 42
217
135
5
E
52 x 54
435
271
6
F
70 x 76
886
553
7
G
104 x 98
1755
1096
8
H
148 x 132
3550
2218
9
S
8x height
18
(not allowed)
10
T
16x height
90
55
Grid matrix
fBarcode.BARCODE_GRIDMATRIX
142
Value can contain Latin-1 and Chinese characters
This type can accept two options:
fBarcode.option1 specifies the error correction:
fBarcode.option1 = 1 — ECC ~10%
fBarcode.option1 = 2 — ECC ~20%
fBarcode.option1 = 3 — ECC ~30%
fBarcode.option1 = 4 — ECC ~40%
fBarcode.option1 = 5 — ECC ~50%
fBarcode.option2 specifies the size:
fBarcode.option2 = 1 – 18x18 symbol
fBarcode.option2 = 2 – 30x30 symbol
fBarcode.option2 = 3 – 42x42 symbol
fBarcode.option2 = 4 – 54x54 symbol
fBarcode.option2 = 5 – 66x66 symbol
fBarcode.option2 = 6 – 78x78 symbol
fBarcode.option2 = 7 – 90x90 symbol
fBarcode.option2 = 8 – 102x102 symbol
fBarcode.option2 = 9 – 114x114 symbol
fBarcode.option2 = 10 – 126x126 symbol
fBarcode.option2 = 11 – 138x138 symbol
fBarcode.option2 = 12 – 150x150 symbol
fBarcode.option2 = 13 – 162x162 symbol
Other Types
Barcode Type
Constant Name
Number
FIM
fBarcode.BARCODE_FIM
49
Value can be A, B, C, or D
Flattermarken
fBarcode.BARCODE_FLAT
28
Value takes a numeric string
DAFT Code
fBarcode.BARCODE_DAFT
93
Value can be a string containing only D, A, F, and T characters
If the string contains other characters, an error will be raised and no symbol will be generated.