FieldDisplayBarcode Class

Implements the DISPLAYBARCODE field.

ExpandedInheritance Hierarchy

SystemObject
  Aspose.Words.FieldsField
    Aspose.Words.FieldsFieldDisplayBarcode

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

ExpandedSyntax

public class FieldDisplayBarcode : Field

The FieldDisplayBarcode type exposes the following members.

ExpandedConstructors

  NameDescription
Public methodFieldDisplayBarcode
Initializes a new instance of the FieldDisplayBarcode class

ExpandedProperties

  NameDescription
Public propertyCode exampleAddStartStopChar
Gets or sets whether to add Start/Stop characters for barcode types NW7 and CODE39.
Public propertyCode exampleBackgroundColor
Gets or sets the background color of the barcode symbol. Valid values are in the range [0, 0xFFFFFF]
Public propertyCode exampleBarcodeType
Gets or sets the barcode type (QR, etc.)
Public propertyCode exampleBarcodeValue
Gets or sets the barcode value.
Public propertyCode exampleCaseCodeStyle
Gets or sets the style of a Case Code for barcode type ITF14. The valid values are [STD|EXT|ADD]
Public propertyCode exampleDisplayResult
Gets the text that represents the displayed field result.
(Inherited from Field.)
Public propertyCode exampleDisplayText
Gets or sets whether to display barcode data (text) along with image.
Public propertyCode exampleEnd
Gets the node that represents the field end.
(Inherited from Field.)
Public propertyCode exampleErrorCorrectionLevel
Gets or sets an error correction level of QR Code. Valid values are [0, 3].
Public propertyCode exampleFixCheckDigit
Gets or sets whether to fix the check digit if it’s invalid.
Public propertyCode exampleForegroundColor
Gets or sets the foreground color of the barcode symbol. Valid values are in the range [0, 0xFFFFFF]
Public propertyCode exampleFormat
Gets a FieldFormat object that provides typed access to field's formatting.
(Inherited from Field.)
Public propertyCode exampleIsDirty
Gets or sets whether the current result of the field is no longer correct (stale) due to other modifications made to the document.
(Inherited from Field.)
Public propertyCode exampleIsLocked
Gets or sets whether the field is locked (should not recalculate its result).
(Inherited from Field.)
Public propertyCode exampleLocaleId
Gets or sets the LCID of the field.
(Inherited from Field.)
Public propertyCode examplePosCodeStyle
Gets or sets the style of a Point of Sale barcode (barcode types UPCA|UPCE|EAN13|EAN8). The valid values (case insensitive) are [STD|SUP2|SUP5|CASE].
Public propertyCode exampleResult
Gets or sets text that is between the field separator and field end.
(Inherited from Field.)
Public propertyCode exampleScalingFactor
Gets or sets a scaling factor for the symbol. The value is in whole percentage points and the valid values are [10, 1000]
Public propertyCode exampleSeparator
Gets the node that represents the field separator. Can be null.
(Inherited from Field.)
Public propertyCode exampleStart
Gets the node that represents the start of the field.
(Inherited from Field.)
Public propertyCode exampleSymbolHeight
Gets or sets the height of the symbol. The units are in TWIPS (1/1440 inch).
Public propertyCode exampleSymbolRotation
Gets or sets the rotation of the barcode symbol. Valid values are [0, 3]
Public propertyCode exampleType
Gets the Microsoft Word field type.
(Inherited from Field.)

ExpandedMethods

  NameDescription
Public methodEquals (Inherited from Object.)
Public methodCode exampleGetFieldCode
Returns text between field start and field separator (or field end if there is no separator). Both field code and field result of child fields are included.
(Inherited from Field.)
Public methodCode exampleGetFieldCode(Boolean)
Returns text between field start and field separator (or field end if there is no separator).
(Inherited from Field.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodCode exampleRemove
Removes the field from the document. Returns a node right after the field. If the field's end is the last child of its parent node, returns its parent paragraph. If the field is already removed, returns null.
(Inherited from Field.)
Public methodToString (Inherited from Object.)
Public methodCode exampleUnlink
Performs the field unlink.
(Inherited from Field.)
Public methodCode exampleUpdate
Performs the field update. Throws if the field is being updated already.
(Inherited from Field.)
Public methodCode exampleUpdate(Boolean)
Performs a field update. Throws if the field is being updated already.
(Inherited from Field.)

ExpandedRemarks

Inserts a barcode.

ExpandedExamples

Shows how to insert a DISPLAYBARCODE field and set its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

FieldDisplayBarcode field = (FieldDisplayBarcode)builder.InsertField(FieldType.FieldDisplayBarcode, true);

// Insert a QR code
field.BarcodeType = "QR";
field.BarcodeValue = "ABC123";
field.BackgroundColor = "0xF8BD69";
field.ForegroundColor = "0xB5413B";
field.ErrorCorrectionLevel = "3";
field.ScalingFactor = "250";
field.SymbolHeight = "1000";
field.SymbolRotation = "0";

Assert.AreEqual(" DISPLAYBARCODE  ABC123 QR \\b 0xF8BD69 \\f 0xB5413B \\q 3 \\s 250 \\h 1000 \\r 0", field.GetFieldCode());
builder.Writeln();

// Insert an EAN13 barcode
field = (FieldDisplayBarcode)builder.InsertField(FieldType.FieldDisplayBarcode, true);
field.BarcodeType = "EAN13";
field.BarcodeValue = "501234567890";
field.DisplayText = true;
field.PosCodeStyle = "CASE";
field.FixCheckDigit = true;

Assert.AreEqual(" DISPLAYBARCODE  501234567890 EAN13 \\t \\p CASE \\x", field.GetFieldCode());
builder.Writeln();

// Insert a CODE39 barcode
field = (FieldDisplayBarcode)builder.InsertField(FieldType.FieldDisplayBarcode, true);
field.BarcodeType = "CODE39";
field.BarcodeValue = "12345ABCDE";
field.AddStartStopChar = true;

Assert.AreEqual(" DISPLAYBARCODE  12345ABCDE CODE39 \\d", field.GetFieldCode());
builder.Writeln();

// Insert an ITF14 barcode
field = (FieldDisplayBarcode)builder.InsertField(FieldType.FieldDisplayBarcode, true);
field.BarcodeType = "ITF14";
field.BarcodeValue = "09312345678907";
field.CaseCodeStyle = "STD";

Assert.AreEqual(" DISPLAYBARCODE  09312345678907 ITF14 \\c STD", field.GetFieldCode());

doc.UpdateFields();
doc.Save(ArtifactsDir + "Field.DISPLAYBARCODE.docx");
Shows how to perform a mail merge on QR barcodes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a MERGEBARCODE field,
// which functions like 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 "MyQRCode" column into QR barcodes
FieldMergeBarcode field = (FieldMergeBarcode)builder.InsertField(FieldType.FieldMergeBarcode, true);
field.BarcodeType = "QR";
field.BarcodeValue = "MyQRCode";

// Edit its appearance such as colors and scale
field.BackgroundColor = "0xF8BD69";
field.ForegroundColor = "0xB5413B";
field.ErrorCorrectionLevel = "3";
field.ScalingFactor = "250";
field.SymbolHeight = "1000";
field.SymbolRotation = "0";

Assert.AreEqual(FieldType.FieldMergeBarcode, field.Type);
Assert.AreEqual(" MERGEBARCODE  MyQRCode QR \\b 0xF8BD69 \\f 0xB5413B \\q 3 \\s 250 \\h 1000 \\r 0",
    field.GetFieldCode());
builder.Writeln();

// 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.Columns.Add("MyQRCode");
table.Rows.Add(new[] { "ABC123" });
table.Rows.Add(new[] { "DEF456" });

doc.MailMerge.Execute(table);

// Every row in the "MyQRCode" 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 \"ABC123\" QR \\q 3 \\s 250 \\h 1000 \\r 0 \\b 0xF8BD69 \\f 0xB5413B", 
    doc.Range.Fields[0].GetFieldCode());
Assert.AreEqual(FieldType.FieldDisplayBarcode, doc.Range.Fields[1].Type);
Assert.AreEqual("DISPLAYBARCODE \"DEF456\" QR \\q 3 \\s 250 \\h 1000 \\r 0 \\b 0xF8BD69 \\f 0xB5413B",
    doc.Range.Fields[1].GetFieldCode());

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

ExpandedSee Also