# Implementing Barcodes as an Ancillary Output Option

Implementing a barcode involves identifying the need to apply a barcode to a document, defining requirements such as appearance, labeling, and the barcode type to apply. Then you must submit the request with the instructions for the barcode and the transaction data to process the barcode instructions.

Barcodes are only applied to documents generated by the Expere Document Services Document Generation Services Expere IE and are added to all generated pages; that is, each generated page in the document and document within a package. The ability to selectively apply barcodes to specific pages in a document is not supported. The barcode object can be submitted as part of the AncillaryOutputObjects on a document generation request to generate barcodes on all documents in a requested package or can be submitted on the DocumentSet or Document object on a document generation request to generate unique barcodes on a document by document basis.

In the DocServicesAPI DocumentServiceAPI ExpereAPI, barcodes are implemented as part of the AncillaryOutputOptions object on several operations used to generate documents, including:

- Generate
- Generate
- Generate
- SelectAndGenerate
- SelectGenerateDeliver
- PostProcess
- SelectGenerateAndSave
- AssembleDocumentSet

Using the DocumentSet object, to apply a unique barcode to individual documents, they are implemented on the following operations:

- Generate
- Generate
- Generate
- SelectAndGenerate
- SelectGenerateDeliver
- PostProcess
- GenerateAndSave
- AssembleDocuments

To implement barcoding on a document through these API calls, you must first define the parameters of the barcode in the Barcode object and then submit that object on the AncillaryOutputOptions object submitted in the request. Following is an example of an AncillaryOutputOptions submitted on a request that will generate a barcode.

    <exp:AncillaryOutput>
     <!--Zero or more repetitions:-->
     <exp:AncillaryOutputOption>
     <exp:OutputType>Barcode</exp:OutputType>
     <exp:Barcode>
     <exp:Type>barcode128</exp:Type>
     <exp:Pattern>Page_%page%_of_%totalpages%_%date%_Doc_%docsequence%_of_%docsequencetotal%</exp:Pattern>
     <exp:UseCoverPage>True</exp:UseCoverPage>
     </exp:Barcode>
     </exp:AncillaryOutputOption>
    </exp:AncillaryOutput>

    <exp:AncillaryOutputOptions>
     <!--Zero or more repetitions:-->
     <exp:AncillaryOutputOption>
     <exp:OutputType>Barcode</exp:OutputType>
     <exp:Barcode>
     <exp:Type>barcode128</exp:Type>
     <exp:Pattern>Page_%page%_of_%totalpages%_%date%_Doc_%docsequence%_of_%docsequencetotal%</exp:Pattern>
     <exp:UseCoverPage>True</exp:UseCoverPage>
     </exp:Barcode>
     </exp:AncillaryOutputOptions>
    </exp:AncillaryOutput>

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

The barcode is rendered on a generated document, as follows: