generate barcode in pdf when using itextsharp to build the pdf

爷,独闯天下 提交于 2019-12-13 16:34:29

问题


i am in trouble with generating a barcode in pdf. i am using itextsharp to generate pdf and i have number from database togenerate this and i am not familiar with barcodes...please help me to generate the barcode.....

i used thefollowing code.. 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()

Regards,

Sivajith S.


回答1:


As you're already working with iText, why not use iText to create the barcode. Go to the examples of chapter 10 of my book and look at Barcodes.cs. The result of this code can be found here.




回答2:


For generating barcode there are exist special libraries. Some of them are free.

For example as option you can use Barcode Image Generation Library to generate barcode as image and then insert this image to pdf using itextsharp library.

Edit I can be wrong that Barcode Image Generation Library currently is free. The things seems to be changed. For free solution you can review the following SO question: Free Barcode API for .NET



来源:https://stackoverflow.com/questions/17495163/generate-barcode-in-pdf-when-using-itextsharp-to-build-the-pdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!