基本上,我想使用iTextSharp将字符串和条形码组合到一个单元格中.从下面的代码可以看出以下两行:
table.AddCell(tempstring);
table.AddCell(new text.Phrase(new text.Chunk(image39, 0, 0)));
Run Code Online (Sandbox Code Playgroud)
下面列出完整的代码
using text = iTextSharp.text;
using pdf = iTextSharp.text.pdf;
text.Document doc = new text.Document();
pdf.PdfWriter writer = pdf.PdfWriter.GetInstance(doc, new FileStream(pdfgen.sWorkPath + "\\OrderNumber" + txtSellerNumber.Text.ToString() + ".pdf", FileMode.Create));
doc.Open();
pdf.PdfContentByte cb = writer.DirectContent;
pdf.Barcode39 code39 = new pdf.Barcode39();
code39.Code = txtSellerNumber.Text.ToString();
code39.StartStopText = false;
text.Image image39 = code39.CreateImageWithBarcode(cb, null, null);
iTextSharp.text.Table table = new iTextSharp.text.Table(3);
table.BorderWidth = 2;
table.BorderColor = new text.Color(0, 0, 255);
table.Padding = 3;
table.Spacing = 1;
text.Cell cell = new …Run Code Online (Sandbox Code Playgroud)