Generate barcode in pdf when using itextsharp to generate pdf file

I am having problems generating barcode in pdf. I am using itextsharp to generate pdf and I have a number from the database to generate this and I am not familiar with barcodes ... help me generate barcode .....

I used the following code. HttpContext.Current.Response.ContentType = "application / pdf" HttpContext.Current.Response.AddHeader ("content-disposition", "attachment; filename = GridViewExport.pdf") HttpContext.Current.Response.CacheNutpCacheCache (HttpContext.Current.Response.CacheNttpCacheCache )

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()

      

Hello,

Sivajit S.

+2


source to share


2 answers


As you already work with iText, why not use iText to generate barcode. Go to the examples in chapter 10 of my book and take a look at Barcodes.cs . The result of this code can be found here .



+2


source


There are special libraries for creating a barcode. Some of them are free.

For example, as an option, you can use the Barcode Image Generation Library to generate a barcode as an image and then insert that image into the pdf using the itextsharp library.



Edit. I could be wrong that the barcode image generation library is free at this time. Everything seems to have changed. For a free solution, you can consider the following SO question: Free Barcode API for .NET

0


source







All Articles