FieldMergeBarcodeAddStartStopChar Property

Gets or sets whether to add Start/Stop characters for barcode types NW7 and CODE39.

Namespace:  Aspose.Words.Fields
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.6


public bool AddStartStopChar { get; set; }

Property Value

Type: Boolean


Shows how to perform a mail merge on CODE39 barcodes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a MERGEBARCODE field,
// which functions similar to a MERGEFIELD by creating a barcode from the merged data source's values
// This field will convert all rows in a merge data source's "MyCODE39Barcode" column into CODE39 barcodes
FieldMergeBarcode field = (FieldMergeBarcode)builder.InsertField(FieldType.FieldMergeBarcode, true);
field.BarcodeType = "CODE39";
field.BarcodeValue = "MyCODE39Barcode";

// Edit its appearance to display start/stop characters
field.AddStartStopChar = true;

Assert.AreEqual(FieldType.FieldMergeBarcode, field.Type);
Assert.AreEqual(" MERGEBARCODE  MyCODE39Barcode CODE39 \\d", field.GetFieldCode());

// Create a DataTable with a column with the same name as our MERGEBARCODE field's BarcodeValue
// When we execute the mail merge,
// a barcode of a type we specified in the MERGEBARCODE field will be created with each row's value
DataTable table = new DataTable("Barcodes");
table.Rows.Add(new[] { "12345ABCDE" });
table.Rows.Add(new[] { "67890FGHIJ" });


// Every row in the "MyCODE39Barcode" column has created a DISPLAYBARCODE field,
// which shows a barcode with the merged value
Assert.AreEqual(FieldType.FieldDisplayBarcode, doc.Range.Fields[0].Type);
Assert.AreEqual("DISPLAYBARCODE \"12345ABCDE\" CODE39 \\d",
Assert.AreEqual(FieldType.FieldDisplayBarcode, doc.Range.Fields[1].Type);
Assert.AreEqual("DISPLAYBARCODE \"67890FGHIJ\" CODE39 \\d",

doc.Save(ArtifactsDir + "Field.MERGEBARCODE.CODE39.docx");

See Also