BarcodeParameters
Contents
[
Hide
]BarcodeParameters class
Container class for barcode parameters to pass-through to BarcodeGenerator.
To learn more, visit the Working with Fields documentation article.
public class BarcodeParameters
Constructors
Name | Description |
---|---|
BarcodeParameters() | The default constructor. |
Properties
Name | Description |
---|---|
AddStartStopChar { get; set; } | Whether to add Start/Stop characters for barcode types NW7 and CODE39. |
BackgroundColor { get; set; } | Bar code background color (0x000000 - 0xFFFFFF) |
BarcodeType { get; set; } | Bar code type. |
BarcodeValue { get; set; } | Data to be encoded. |
CaseCodeStyle { get; set; } | Style of a Case Code for barcode type ITF14. The valid values are [STD|EXT|ADD] |
DisplayText { get; set; } | Whether to display barcode data (text) along with image. |
ErrorCorrectionLevel { get; set; } | Error correction level of QR Code. Valid values are [0, 3]. |
FacingIdentificationMark { get; set; } | Type of a Facing Identification Mark (FIM). |
FixCheckDigit { get; set; } | Whether to fix the check digit if it’s invalid. |
ForegroundColor { get; set; } | Bar code foreground color (0x000000 - 0xFFFFFF) |
IsBookmark { get; set; } | Whether PostalAddress is the name of a bookmark. |
IsUSPostalAddress { get; set; } | Whether PostalAddress is a U.S. postal address. |
PosCodeStyle { get; set; } | Style of a Point of Sale barcode (barcode types UPCA|UPCE|EAN13|EAN8). The valid values (case insensitive) are [STD|SUP2|SUP5|CASE]. |
PostalAddress { get; set; } | Barcode postal address. |
ScalingFactor { get; set; } | Scaling factor for the symbol. The value is in whole percentage points and the valid values are [10, 1000]. |
SymbolHeight { get; set; } | Bar code image height (in twips - 1/1440 inches) |
SymbolRotation { get; set; } | Rotation of the barcode symbol. Valid values are [0, 3]. |
Remarks
The set of parameters are according to DISPLAYBARCODE field options. See the exact list at https://msdn.microsoft.com/en-us/library/hh745901(v=office.12).aspx
Examples
Shows how to use a barcode generator.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use a custom IBarcodeGenerator implementation to generate barcodes,
// and then insert them into the document as images.
doc.FieldOptions.BarcodeGenerator = new CustomBarcodeGenerator();
// Below are four examples of different barcode types that we can create using our generator.
// For each barcode, we specify a new set of barcode parameters, and then generate the image.
// Afterwards, we can insert the image into the document, or save it to the local file system.
// 1 - QR code:
BarcodeParameters barcodeParameters = new BarcodeParameters
{
BarcodeType = "QR",
BarcodeValue = "ABC123",
BackgroundColor = "0xF8BD69",
ForegroundColor = "0xB5413B",
ErrorCorrectionLevel = "3",
ScalingFactor = "250",
SymbolHeight = "1000",
SymbolRotation = "0"
};
Image img = doc.FieldOptions.BarcodeGenerator.GetBarcodeImage(barcodeParameters);
#if NET461_OR_GREATER || JAVA
img.Save(ArtifactsDir + "FieldOptions.BarcodeGenerator.QR.jpg");
#elif NET5_0_OR_GREATER
using (SKFileWStream fs = new SKFileWStream(ArtifactsDir + "FieldOptions.BarcodeGenerator.QR.jpg"))
{
img.Encode(fs, SKEncodedImageFormat.Jpeg, 100);
}
#endif
builder.InsertImage(img);
// 2 - EAN13 barcode:
barcodeParameters = new BarcodeParameters
{
BarcodeType = "EAN13",
BarcodeValue = "501234567890",
DisplayText = true,
PosCodeStyle = "CASE",
FixCheckDigit = true
};
img = doc.FieldOptions.BarcodeGenerator.GetBarcodeImage(barcodeParameters);
#if NET461_OR_GREATER || JAVA
img.Save(ArtifactsDir + "FieldOptions.BarcodeGenerator.EAN13.jpg");
#elif NET5_0_OR_GREATER
using (SKFileWStream fs = new SKFileWStream(ArtifactsDir + "FieldOptions.BarcodeGenerator.EAN13.jpg"))
{
img.Encode(fs, SKEncodedImageFormat.Jpeg, 100);
}
#endif
builder.InsertImage(img);
// 3 - CODE39 barcode:
barcodeParameters = new BarcodeParameters
{
BarcodeType = "CODE39",
BarcodeValue = "12345ABCDE",
AddStartStopChar = true
};
img = doc.FieldOptions.BarcodeGenerator.GetBarcodeImage(barcodeParameters);
#if NET461_OR_GREATER || JAVA
img.Save(ArtifactsDir + "FieldOptions.BarcodeGenerator.CODE39.jpg");
#elif NET5_0_OR_GREATER
using (SKFileWStream fs = new SKFileWStream(ArtifactsDir + "FieldOptions.BarcodeGenerator.CODE39.jpg"))
{
img.Encode(fs, SKEncodedImageFormat.Jpeg, 100);
}
#endif
builder.InsertImage(img);
// 4 - ITF14 barcode:
barcodeParameters = new BarcodeParameters
{
BarcodeType = "ITF14",
BarcodeValue = "09312345678907",
CaseCodeStyle = "STD"
};
img = doc.FieldOptions.BarcodeGenerator.GetBarcodeImage(barcodeParameters);
#if NET461_OR_GREATER || JAVA
img.Save(ArtifactsDir + "FieldOptions.BarcodeGenerator.ITF14.jpg");
#elif NET5_0_OR_GREATER
using (SKFileWStream fs = new SKFileWStream(ArtifactsDir + "FieldOptions.BarcodeGenerator.ITF14.jpg"))
{
img.Encode(fs, SKEncodedImageFormat.Jpeg, 100);
}
#endif
builder.InsertImage(img);
doc.Save(ArtifactsDir + "FieldOptions.BarcodeGenerator.docx");
See Also
- namespace Aspose.Words.Fields
- assembly Aspose.Words