BarcodeParameters
内容
[
隐藏
]
BarcodeParameters class
条码参数的容器类传递给 BarcodeGenerator.
public class BarcodeParameters
构造函数
姓名 | 描述 |
---|---|
BarcodeParameters() | 默认构造函数。 |
特性
姓名 | 描述 |
---|---|
AddStartStopChar { get; set; } | 是否为条形码类型 NW7 和 CODE39 添加开始/停止字符。 |
BackgroundColor { get; set; } | 条码背景颜色 (0x000000 - 0xFFFFFF) |
BarcodeType { get; set; } | 条码类型. |
BarcodeValue { get; set; } | 要编码的数据。 |
CaseCodeStyle { get; set; } | 条码类型 ITF14 的案例代码样式。有效值为 [STD|EXT|ADD] |
DisplayText { get; set; } | 是否与图像一起显示条形码数据(文本)。 |
ErrorCorrectionLevel { get; set; } | QR 码的纠错级别。有效值为 [0, 3]. |
FacingIdentificationMark { get; set; } | 正面识别标记 (FIM) 的类型。 |
FixCheckDigit { get; set; } | 校验位无效时是否修复 |
ForegroundColor { get; set; } | 条码前景色 (0x000000 - 0xFFFFFF) |
IsBookmark { get; set; } | 是否PostalAddress 是书签的名称。 |
IsUSPostalAddress { get; set; } | 是否PostalAddress 是美国邮政地址。 |
PosCodeStyle { get; set; } | POS 条码样式(条码类型 UPCA|UPCE|EAN13|EAN8)。有效值(不区分大小写)为 [STD|SUP2|SUP5|CASE]. |
PostalAddress { get; set; } | 条形码邮政地址。 |
ScalingFactor { get; set; } | 符号的比例因子。该值以整数为单位,有效值为 [10, 1000]. |
SymbolHeight { get; set; } | 条码图像高度(缇 - 1/1440 英寸) |
SymbolRotation { get; set; } | 条码符号的旋转。有效值为 [0, 3]. |
评论
参数集根据 DISPLAYBARCODE 字段选项而定。 详细列表见https://msdn.microsoft.com/en-us/library/hh745901(v=office.12).aspx
例子
展示如何使用条形码生成器。
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// 我们可以使用自定义的 IBarcodeGenerator 实现来生成条形码,
// 然后将它们作为图像插入到文档中。
doc.FieldOptions.BarcodeGenerator = new CustomBarcodeGenerator();
// 下面是我们可以使用生成器创建的不同条形码类型的四个示例。
// 对于每个条码,我们指定一组新的条码参数,然后生成图像。
// 之后,我们可以将图片插入到文档中,或者保存到本地文件系统中。
// 1 - 二维码:
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);
img.Save(ArtifactsDir + "FieldOptions.BarcodeGenerator.QR.jpg");
builder.InsertImage(img);
// 2 - EAN13 条形码:
barcodeParameters = new BarcodeParameters
{
BarcodeType = "EAN13",
BarcodeValue = "501234567890",
DisplayText = true,
PosCodeStyle = "CASE",
FixCheckDigit = true
};
img = doc.FieldOptions.BarcodeGenerator.GetBarcodeImage(barcodeParameters);
img.Save(ArtifactsDir + "FieldOptions.BarcodeGenerator.EAN13.jpg");
builder.InsertImage(img);
// 3 - CODE39 条形码:
barcodeParameters = new BarcodeParameters
{
BarcodeType = "CODE39",
BarcodeValue = "12345ABCDE",
AddStartStopChar = true
};
img = doc.FieldOptions.BarcodeGenerator.GetBarcodeImage(barcodeParameters);
img.Save(ArtifactsDir + "FieldOptions.BarcodeGenerator.CODE39.jpg");
builder.InsertImage(img);
// 4 - ITF14 条形码:
barcodeParameters = new BarcodeParameters
{
BarcodeType = "ITF14",
BarcodeValue = "09312345678907",
CaseCodeStyle = "STD"
};
img = doc.FieldOptions.BarcodeGenerator.GetBarcodeImage(barcodeParameters);
img.Save(ArtifactsDir + "FieldOptions.BarcodeGenerator.ITF14.jpg");
builder.InsertImage(img);
doc.Save(ArtifactsDir + "FieldOptions.BarcodeGenerator.docx");
也可以看看
- 命名空间 Aspose.Words.Fields
- 部件 Aspose.Words