DAutomationHC39M字体显示与iTextSharp一起使用时的背景栏

时间:2017-04-19 16:07:28

标签: c# itext

我正在尝试在我的PDF文件中使用“IDAutomationHC39M Free Version.ttf”字体。 该文件是使用iTextSharp生成的。

生成文件,但查看PDF时,它看起来像这样: without font as font was not embedded 请看中间的酒吧。

当我在PDF文档中嵌入字体时,它看起来像这样: see the bar in the box

我的代码如下:

Barcode39 barcode39 = new Barcode39();

var barcodeValue = "";

// ID Automation Font

string file = System.Web.HttpContext.Current.Server.MapPath("~//fonts//IDAutomationHC39M Free Version.ttf");

var baseFnt = BaseFont.CreateFont(file, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

document.Open();
barcodeValue = "10000007300045487901"; // Code in the sample pdf
barcode39.Code = barcodeValue;

var BarCodeHeight= float.Parse(WebConfigurationManager.AppSettings["BarCodeHeight"]);
var BarCodeX     = float.Parse(WebConfigurationManager.AppSettings["BarCodeX"]);
var BarCodeLocX  = float.Parse(WebConfigurationManager.AppSettings["BarCodeLocX"]);
var BarCodeLocY  = float.Parse(WebConfigurationManager.AppSettings["BarCodeLocY"]);
var BarCodeInk   = float.Parse(WebConfigurationManager.AppSettings["BarCodeInk"]);
var BarCodeArLocX= float.Parse(WebConfigurationManager.AppSettings["BarCodeArLocX"]);
var BarCodeArLocY= float.Parse(WebConfigurationManager.AppSettings["BarCodeArLocY"]);

barcode39.GuardBars = true;
barcode39.ChecksumText = true;
barcode39.BarHeight = BarCodeHeight;
barcode39.X = BarCodeX;
//barcode39.InkSpreading = BarCodeInk; // Comment out this for ID Automation Font
//barcode39.StartStopText = false;

barcode39.Font = baseFnt; // ID Automation Font

iTextSharp.text.Image img2 = barcode39.CreateImageWithBarcode(cb, null, null);

0 个答案:

没有答案