Customizing the Barcode

The XMPBarcode function can optionally have a third parameter specifying further barcode customizations. This parameter can be added, for example, to set the color of the barcode. For one-dimensional barcodes, you can use it to set up the module (line) width.

The following options can be controlled by the third parameter for all barcodes:

  • Module width parameter: sets up the module width for one-dimensional barcodes.

  • Barcode width parameter: specifies the reduction of the bar-widths.

  • Height parameter: sets up the barcode height for one-dimensional barcodes.

  • CodePage parameter: determines the Code Page used to encode the barcode string in the selected barcode symbology.

  • BinaryString parameter: treats the input as a stream of binary data that is not affected by the CodePage.

  • Color parameters: customizes your barcode by setting a different color to the barcode text, barcode image, and to the background of the barcode image.

  • HideReadableText parameter: hides the Human Readable Text caption in one-dimensional barcodes.

  • FontSize parameter: determines the font size of the Human Readable Text in one-dimensional barcodes.

  • Checksum: enables or disables the Check Digit option.

  • EscapeSequences: activates the encoding of escape characters into the barcode string input.

  • BarShape: used to customize the barcode bars (rectangle, rounded rectangle, ellipse or big ellipse).

To add a third parameter:

  1. Add a comma (,) after your encoded text.

  2. Add a string QLingo parameter: quotation marks ('') surrounding the third parameter name (for example, ModuleWidth) and its custom value.

  3. If you want to combine multiple options, separate them with a semi-colon (;).

Example 1

XMPBarcode("Code128", "01234567", "ModuleWidth=508")

In this example, the third parameter is used to set up the module width for a Code 128 barcode. The parameter’s key (ModuleWidth) and value (508) are separated by the equal (=) sign and are surrounded by the quotation marks ('').

Example 2

XMPBarcode("Code128", "01234567", "ModuleWidth=508;Color=rgb(255,0,0)")

This example sets up the color of the barcode in addition to its module width.

Note how the ModuleWidth option is separated from the Color option by a semi-colon (;). The quotation marks ('') surround the entire third parameter expression.

Module width parameter

The Module Width is the width of the barcode's smallest element. It is specified in units of thousandths of a millimeter (1/1000mm). By default, the module width is set to 0.254 mm.

Barcode_Module_Width.png

Example:XMPBarcode("Code128", "1234567890", "ModuleWidth=508")

Barcode width parameter

Sets bar-width (Pixel-Shaving) reduction in given unit.

Specifies the reduction of the bar-widths. The width of a bar in the barcode is reduced by the given value in the given unit. This property is useful when printing on ink jet printers: On such printers the bars appear wider than specified because the ink spreads a little bit. You can compensate this effect by setting a bar-width reduction (also called "Pixel Shaving") to an suitable value. You have to play around to find suitable settings because this effect depends on the printer, on the used paper, and on the ink. The printed module-width is equal to the theoretically optimal module-width reduced by the reduction value.

Example:XMPBarcode("Code128", "1234567890", "WidthReduction=0.1") where 0.1 is the reduction size in mm.

Height parameter

The Height parameter specifies the barcode’s height in units of a millimeter. When this parameter is not used, the default height is selected.

Example:XMPBarcode("Code128", "1234567890", "Height=20")

CodePage parameter

You may want to control the Code Page of the barcode. A Code Page defines how text characters are encoded. For all barcode symbologies, the default Code Page is UTF-8. You can set a different Code Page using the CodePage parameter.

Notes:

  • If your input data contains characters that are not part of the default code page, these characters are lost (do not appear in the barcode).

  • If the default Code Page is not the one your barcode reader expects, the wrong information (other characters) appears in the barcode.

Possible values are:

  • Default - UTF-8

  • Local -the Code Page that is set in the machine’s Regional and Language Options.

  • Windows1252

  • ISO8859-1

  • ASCIIExtended437

  • UTF8

  • Korean949

  • ShiftJIS932

  • SimplifiedChinese936

  • TraditionalChinese950

  • ANSICyrillic1251

  • KOI8-R20866

The following example shows how to set the code page for a QR code to ShiftJIS932:

XMPBarcode("QRCode", ''http:www.xmpie.com/udirect'', "CodePage=ShiftJIS932") 

BinaryString parameter

You can direct the XMPBarcode function to encode the input string as is. To do so, use the BinaryString parameter. This is useful when you would like to encode binary characters that cannot be represented as text.

You can customize the Barcode’s BinaryString parameter by setting it to one of the following values:

  • false: treats the input as a text string.

  • true:treats the input as a stream of binary data.

  • hex: treats the input as a stream of binary data, represented in hexadecimal numbers. Each pair of characters represents a single byte.

Example:XMPBarcode("Code128","02DC","BinaryString=hex")

In this example, the barcode function encodes the FNC1 character, that cannot be represented as text, for a Code 128 barcode.

Color parameters

You can customize your barcode by adding color. A different color can be set to the barcode text, barcode image, and to the background of the barcode image.

The following parameters allow you to customize color:

  • Color: controls the barcode image

  • BackgroundColor: controls the background of the image

  • FontColor: controls the text of the barcode, when text is used

Each of the color parameters may receive a CMYK or RGB color space value. The BackgroundColor parameter can also be set to be transparent by using the keyword "none" (BackgroundColor=none). PDF and PDF/VT output formats also support the Transparent background option in barcodes.

There are several syntaxes that you can use to describe the color values. The example below provides the RGB color using a range of 0 to 255.

Example:XMPBarcode("Code128","123","Color=rgb(0,255,0)")

rgb(0,255,0)translates to 0 value for red, 255 value for green, and 0 value for blue, which results in a green color for the barcode.

The full list of formatting options is:

#RRGGBB: hexadecimal pairs for RGB color. Values are between 0 and FF. For example, #00FF00 is green.

#CCMMYYKK: hexadecimal pairs for CMYK color. Values are between 0 and FF. For example, #00FF0000 is magenta.

rgb(R%,G%,B%): percentage of color for RGB color. Values are between 0% and 100%. For example rgb(0%,100%,0%) is green.

cmyk(C%,M%,Y%,K%): percentage of color for CMYK color. Values are between 0% and 100%. For example cmyk(0%,100%,0%,0%) is magenta.

rgb(R,G,B): decimal value of color for RGB color. Values are between 0 and 255. For example rgb(0,255,0) is green.

cmyk(C,M,Y,K): decimal value of color for CMYK color. Values are between 0 and 255. For example cmyk(0,255,0,0) is magenta.

Example: QR Code with a color parameter

XMPBarcode("QRCode", "http://www.xmpie.com", "Color=rgb(100%,0%,0%);")

Barcode_QRCode_Color.png

Example: QR Code with a color and background color parameter

XMPBarcode("QRCode", "http://www.xmpie.com", "Color=cmyk(100%,0%,100%,0%);BackgroundColor=cmyk(0%,0%,100%,0%);")

Barcode_QRCode_Color_Background.png

Spot colors

Barcodes can also be drawn with spot colors.

The spot color name uses the command: “SpotColor=<string>”, BackgroundSpotColor or FontSpotColor.

Each of the parameters has a dependent mandatory parameter:

  • SpotColor is dependent on Color 

  • BackgroundSpotColor  is dependent on BackgroundColor

  • FontSpotColor  is dependent on FontColor

Note that only CMYK values can be used for spot colors.

Example: QR Code with spot colors

XMPBarcode("QRCode", "www.xmpie.com", "Color=cmyk(40.05%, 47.93%, 76.67%, 17.04%);BackgroundColor=cmyk(100%,0,0,0); SpotColor = PANTONE 872 C")

Notes:

  • Spot colors are dependent upon color values being first defined.

  • This capability is supported only for    PDF and PDF/VT output formats.

  • The feature works for all InDesign-based workflows in uProduce. It works for XLIM if uProduce has InDesign server installed (in uProduce XLIM Edition configuration this feature is not supported).

HideReadableText parameter

Used to hide the Human Readable Text caption in one-dimensional barcodes.

Example:XMPBarcode("Code128", "1234567890", "HideReadableText=true")

The supported values are:

true- hide Human Readable Text

false-show Human Readable Text

FontSize Parameter

Determines the font size of the Human Readable Text.

Example:XMPBarcode("Code128", "1234567890", "FontSize=15")

Checksum

The Checksum parameter determines if the Check Digit is displayed or not in the barcode. The Check Digit is one or more characters included within the barcode which are used to perform a mathematical check to ensure the accuracy of the scanned data. Check digits are mandatory with certain barcodes or are even built into the symbology.

Example:XMPBarcode("Code128", "1234567890", "Checksum=1")

1-calculate and show the Check Digit

0- hide the Check Digit (for barcodes which have the Check Digit by default).

Note: For PDF417 barcode, the Checksum parameter uses different values (see PDF417).

EscapeSequences

If you want to use non-printable or special characters in a barcode, you must use escape sequences. An escape sequence always starts with a backslash (‘\’) followed by the sequence itself.

Supported values are:

  • True - activate EscapeSequences

  • False - disable EscapeSequences (default option)

When the parameter is omitted, the default value is false.

Example:XMPBarcode("USPSIMPackage", "420123456789\\F9212391234567812345670", "EscapeSequences=true")

In certain cases, you may need to indicate to the software that there is additional information in the barcode; e.g. routing information.

The FNC1 character is an invisible character used to identify and separate fields for variable length application identifiers. An application identifier is used to identify the meaning of the data encoded.

It is possible to add the FNC1 character by inserting “\\F” into the string where the character is needed.

If you use a standard barcode function such as:

XMPBarcode("USPSIMPackage", |->[ADOR_name], "")

You will get the following result:

In the following code FNC1 is placed at position 13:

XMPBarcode("USPSIMPackage ", substring(|->[ADOR_name],0,12) & "\\F" & substring(|->[ADOR_name],13,Length(|->[ADOR_name])), " EscapeSequences=true")

The result is:

Bar Shape

You can customize the barcode bars (also called "modules" or "cells").

For standard use we strongly recommend to use only the "Default" bar shape. Using another mode can endanger readability of the barcode.

Changing it does make sense only for special applications like advertisements, fun barcodes, etc., that do not enforce the readability of the barcodes.

The following shapes are supported:

  • Default: The bars of the barcode are drawn in their default shape.

  • Rectangle: The bars of the barcode are drawn as rectangles.

  • RoundedRectangle: The bars of the barcode are drawn as rounded rectangles.

  • Ellipse: The bars of the barcode are drawn as circles or ellipses.

  • BigEllipse: The bars of the barcode are drawn as big circles or ellipses.

The Ellipse and BigEllipse are only supported when the barcode is generated in Postscript. You can enforce the barcode to be generated in a certain type (Postscript or PDF) by adding OutputType=Postscript as an additional parameter. It is important that you take into account that changing the output type will affect performance, especially in XLIM.

Example of RoundedRectanlge bar shape:

XMPBarcode("QRCode",FormatNumber((|->{index},"00000000000000),"BarShape=RoundedRectangle")

Example of ellipse bar shape:

XMPBarcode("QRCode",FormatNumber((|->{index},"00000000000000),"BarShape=Ellipse;OutputType=PostScript")