# Barcode Types (Fonts) and Patterns

The barcode type and options for including both text, document parameters, and delimiters for parameters are defined on the Barcode object in the BarcodeType enumeration and Pattern parameter.

## Barcode Types (Fonts)

Use this enumeration to identify the type of barcode font to generate. This field allows one of four font options for the barcode as enumerated options on the request. The available font options include: Code39, Code128, Inter25, and 2D (PDF417). Submitting this field allows you to specify the desired barcode font. Generally speaking, code 39 is very commonly used and suggested if using the tagline element to author a barcode while code 128 is visually more dense than code 39.

DocGenServices supports four industry-standard barcode types:

- Code 128 (barcode128) - Code 128 is used for alphanumeric or numeric-only barcodes and uses all 128 ASCII characters
- Code 39 (barcode39) - Also referred to as 3 of 9 or 3.9. Code 39 uses 43 characters including uppercase letters (A through Z), numeric digits (0 through 9) and a number of special characters (-, ., $, /, +, %, and space).
- Inter25 (barcodeInter25) - Also referred to as 2 of 5.
- 2D Symbolism (barcode2D) - This option produces a barcode based on the PDF 417 definition.

## Barcode Components (Patterns)

The mechanism to apply specific values to a barcode on a per-document-request basis is to include a Pattern parameter on Barcode object in the request. This allows a barcode to be constructed with one or more optional components;

- %page% - individual page number of the document
- %totalpages% - the total number of pages for the document
- %docsequence% - the doc sequence number
- %docsequencetotal% - the total doc sequence number
- %docname% - the instance display name of the document
- %date% - the current system date in MM/DD/YYYY format
- %BRCD . . .% - the custom barcode pattern containing optional characters

You can also include document metadata for presentation in the barcode.

The order of parts in the pattern string does not matter; whatever order is presented in the string defines the order of presentation. Text can be added anywhere is the string to establish a unique name or to set delimiters between any of the components. In this example, the barcode is defined to generate with the total numbers of pages, the instance display name of the document, and the system date with a [ _ ] added as the de facto delimiter for each value.

    <exp:Barcode>
     <exp:Type>barcode128</exp:Type>
     <exp:Pattern>Page_%page%_of_%totalpages%_%date%_Doc_%docsequence%_of_%docsequencetotal%</exp:Pattern>
    </exp:Barcode>

The example renders a barcode that looks like this:

Note: The practice of entering a document name as text is used mainly when placing the Barcode on a document-by-document basis with a DocumentSet. It can be used, with either the AncillaryOutputOption or DocumentSet approaches, to add a document name that may differ from the instance display name (or may be a shortened version of the full document name).