2

我无法在 pdf 中生成条形码。我正在使用 itextsharp 生成 pdf,我有数据库中的数字来生成这个,我不熟悉条形码...请帮我生成条形码.....

我使用了以下代码.. HttpContext.Current.Response.ContentType = "application/pdf" HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf") HttpContext.Current.Response.Cache .SetCacheability(HttpCacheability.NoCache)

Dim pdfDoc As New Document()
PdfWriter.GetInstance(pdfDoc, HttpContext.Current.Response.OutputStream)

pdfDoc.Open()
'WRITE PDF <<<<<<

pdfDoc.Add(New Paragraph("My first PDF"))

'END WRITE PDF >>>>>
pdfDoc.Close()

HttpContext.Current.Response.Write(pdfDoc)
HttpContext.Current.Response.End()

问候,

西瓦吉斯·S。

4

2 回答 2

2

由于您已经在使用 iText,为什么不使用 iText 创建条形码。转到我的书第 10 章的示例并查看Barcodes.cs。可以在此处找到此代码的结果。

于 2013-07-06T07:21:06.310 回答
0

为了生成条形码,存在特殊的库。其中一些是免费的。

例如,作为选项,您可以使用条码图像生成库将条码生成为图像,然后使用 itextsharp 库将此图像插入 pdf。

编辑我可能错了,条形码图像生成库目前是免费的。事情似乎变了。对于免费解决方案,您可以查看以下 SO 问题:Free Barcode API for .NET

于 2013-07-05T20:50:06.760 回答