2

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.

Sivajith
  • 1,181
  • 5
  • 19
  • 38

2 Answers2

2

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.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
0

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

Community
  • 1
  • 1
Maxim Kornilov
  • 5,675
  • 1
  • 24
  • 35
  • You're advising the use of raster images of barcodes that are to be inserted into a PDF file. That's not always the best option. When using the native barcode functionality in iTextSharp, the images are added as vector data which makes printing them much more reliable than using raster images. – Bruno Lowagie Jul 06 '13 at 07:22