.NET条形码的iText
我尝试使用iTextSharp库创建带有EAN13条码的PDF。 我尝试生成一个值为“023942432852”的条形码 抛出.NET条形码的iText,itext,barcode,ean-13,Itext,Barcode,Ean 13,我尝试使用iTextSharp库创建带有EAN13条码的PDF。 我尝试生成一个值为“023942432852”的条形码 抛出系统。IndexOutOfRangeException 代码如下: Document pdfdoc = new Document(pageSize, _margSx, _margDx, _margUp, _margBo); PdfWriter writer = PdfWriter.GetInstance(pdfdoc, new FileStream
系统。IndexOutOfRangeException
代码如下:
Document pdfdoc = new Document(pageSize, _margSx, _margDx, _margUp, _margBo);
PdfWriter writer = PdfWriter.GetInstance(pdfdoc, new FileStream(_path + @"\Barcode.pdf", FileMode.Create));
pdfdoc.Open();
PdfContentByte cb = writer.DirectContent;
pdfdoc.PageSize.BackgroundColor = BaseColor.GRAY;
BarcodeEAN codeEan = new BarcodeEAN();
if (CreaChecksum)
codeEan.GenerateChecksum = true;
codeEan.ChecksumText = true;
codeEan.CodeType = Barcode.EAN13;
codeEan.Code = barcode;
iTextSharp.text.Image imageEAN = codeEan.CreateImageWithBarcode(cb, null, null);
imageEAN.ScaleAbsolute(100, 40);
imageEAN.SetAbsolutePosition(pdfdoc.PageSize.Right - 150f, pdfdoc.PageSize.Bottom + 30f);
pdfdoc.Add(imageEAN);
正如名称所示,EAN13条码需要13位数字,就像EAN8条码需要8位数字一样。您正在尝试为此
字符串创建条形码
:
"023942432852"
当我计算这个
字符串中的位数时,我只找到12位。少了一个数字。请填写字符串
,使其长度为13。猜测一下,它失败了,因为指定的条形码只有12位。谢谢您的回答。
"023942432852"