Skip to main content
A newer version of this page is available. .

How to: Create Barcode

To create a barcode in a snap document, do the following:

  1. Call the IRichEditDocumentServer.LoadDocumentTemplate method to load the document template and open it for modification by calling the SubDocument.BeginUpdateCharacters method.
  2. Create a new SnapBarCode object by calling the ISnapFieldOwner.CreateSnBarCode method with the barcode placement position passed as a parameter.
  3. Call the ISnapFieldOwner.ParseField to convert the barcode field to a Snap Field. Note that if this step is skipped, you won’t be able to modify the barcode.
  4. Call the SnapEntity.BeginUpdate method to open the barcode for modification.
  5. Specify the desired barcode settings, such as orientation (SnapBarCode.Orientation), module (SnapBarCode.Module), and alignment (SnapBarCode.Alignment), etc.
  6. Finalize the modification by calling the SnapEntity.EndUpdate method.
  7. Call the FieldCollection.Update method to update the document fields.
Dim barcode As SnapBarCode = server.Document.CreateSnBarCode(server.Document.Range.Start)
barcode.DataFieldName = "EAN13"
barcode.Module = 10
barcode.Orientation = DevExpress.XtraPrinting.BarCode.BarCodeOrientation.Normal
barcode.AutoModule = True
barcode.ShowData = False