I was pleasantly surprised to find that iText (iTextSharp) has been ported to the .Net world without any dependencies on the J# runtime. Below is a sample piece of code to generate a barcode as a png file
private void GenerateBarCode(string strBarCodeValue) {
//Barcode
Response.ContentType = "image/png";
MemoryStream stream = new MemoryStream();
Document doc = new Document(PageSize.A4, 50, 50, 50, 50);
PdfWriter writer = PdfWriter.GetInstance(doc, stream);
doc.Open();
PdfContentByte cb = writer.DirectContent;
Barcode39 code39 = new Barcode39();
code39.Code = strBarCodeValue;
code39.StartStopText = true;
code39.GenerateChecksum = false;
code39.Extended = true;
MemoryStream mem = new MemoryStream();
code39.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White)
.Save("E:\\abcd.png");
}
7 comments:
Interesting but :
- this Barcode class you are using is part of iText?
- I don't see any link between the Barcode instanciation and the iText document?
Yes, the barcode is actually a part of the iTextSharp library. Fullname for the class is iTextSharp.text.pdf.Barcode39
As far as the iText document is concerned, I only needed it to generate my png image.
Twinz Lover,
We are seeking a consultant to assist us with developing a method for using iTextSharp to flatten annotations inside a PDF. I was wondering if you would have interest in helping us with this, or if you could recommend others who we could contact.
We need to be able to flatten all annotations inside a PDF. We have found that the setFreeTextFlattening method in iTextSharp will flatten text-based elements, but it does not apply to graphical annotations such as lines, shapes, revisions clouds, and stamps.
We will pay a consulting fee for assistance with this project. Please let me know if you could help or if you could recommend others who we could contact. Thank you.
Matt
Email: ostkm@yahoo.com
How to add the Barcode to a Pdf document created using iTextSharp.dll and save it to a dersired location?
How to add Barcode to a pdf document created using iTextSharp.dll?
Can you change the size of the barcode? I've got my app creating the barcode but I cannot adjust the height. Any ideas?
Jonathan
//This will drive the height of the barcode in the above example
code39.BarHeight = 100f;
Post a Comment