I need to create a barcode with upper and lower text and apply it on all the page of a PDF as the following structure:
TEXT
BARCODE
TEXT
I'm using the iTextSharp DLL to create the barcode. My idea is create a JPG image (with the structure) and apply on the PDF.
I have used this code:
Bmgraphics.Clear(Drawing.Color.White)
Bmgraphics.DrawString(UpperText, New System.Drawing.Font("Arial", 8, FontStyle.Regular), SystemBrushes.WindowText, New Point(0, 0))
Bmgraphics.DrawImage(Barcode, New Point(0, height/ 2))
Bmgraphics.DrawString(LoewText, New System.Drawing.Font("Arial", 8, FontStyle.Regular), SystemBrushes.WindowText, New Point(0, height+ 10))
finale.Save("path to save")
My problem is about the dimension to give to the Bitmap image. I need that the longer between barcode, lower text, and upper text give the width of the image.
How can I do?
Graphicsobject? If so, you can useMeasureStringto get the sizes of the two strings, and thenMath.Maxto find the larger of those two widths and Barcode.Width. - pmcoltrane