【问题标题】:generate barcode in pdf when using itextsharp to build the pdf使用 itextsharp 构建 pdf 时生成 pdf 中的条形码
【发布时间】:2013-07-03 22:15:39
【问题描述】:

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

我使用了以下代码.. HttpContext.Current.Response.ContentType = "应用程序/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()

问候,

Sivajith S.

【问题讨论】:

    标签: asp.net itextsharp barcode


    【解决方案1】:

    既然您已经在使用 iText,为什么不使用 iText 创建条形码。转到chapter 10 of my book 的示例并查看Barcodes.cs。这段代码的结果可以在here找到。

    【讨论】:

      【解决方案2】:

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

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

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

      【讨论】:

      • 您建议使用要插入 PDF 文件的条码光栅图像。这并不总是最好的选择。在 iTextSharp 中使用原生条码功能时,图像被添加为矢量数据,这使得打印它们比使用光栅图像更可靠。
      猜你喜欢
      • 2011-07-27
      • 2021-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-29
      • 1970-01-01
      相关资源
      最近更新 更多