1
我改寫的iText的(Java)的實施例 http://itextpdf.com/examples/iia.php?id=297 在iTextSharp的(C#)這樣的..iTextSharp的IndexOutOfRange異常時添加一個條形碼等文檔
var document = new Document(PageSize.A4);
var writer = PdfWriter.GetInstance(document,
new FileStream(Path, FileMode.Create, FileAccess.Write,
FileShare.None));
document.Open();
var cb = writer.DirectContent;
document.Add(new Paragraph("Barcode EAN.UCC-13"));
var codeEan = new BarcodeEAN {Code = "230482304"};
document.Add(new Paragraph("default:"));
document.Add(codeEan.CreateImageWithBarcode(cb, BaseColor.BLACK, BaseColor.WHITE));
codeEan.GuardBars = false;
document.Add(new Paragraph("without guard bars:"));
Image i = codeEan.CreateImageWithBarcode(cb, null, null);
document.Add(i);
codeEan.Baseline = -1f;
codeEan.GuardBars = true;
document.Add(new Paragraph("text above:"));
document.Add(codeEan.CreateImageWithBarcode(cb, null, null));
codeEan.Baseline = codeEan.Size;
document.Close();
但要下列例外
Index was outside the bounds of the array.
at iTextSharp.text.pdf.BarcodeEAN.GetBarsEAN13(String _code)
at iTextSharp.text.pdf.BarcodeEAN.PlaceBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor)
at iTextSharp.text.pdf.Barcode.CreateTemplateWithBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor)
at iTextSharp.text.pdf.Barcode.CreateImageWithBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor)
我的錯誤在哪裏?它的1:1在那裏的例子頁...我沒有找到C#的東西,但一個C#端口,沒有Doku是一點點......沒有。
謝謝,有時我覺得很複雜:)現在工作很好 – slopsucker