0
votes

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?

1
Is Bmgraphics a Graphics object? If so, you can use MeasureString to get the sizes of the two strings, and then Math.Max to find the larger of those two widths and Barcode.Width. - pmcoltrane
Thanks man, i have found this solution and i have used this one. it's work fine! - loris1243

1 Answers

0
votes

A readable barcode, AFAIK, is always longer than the underlying text. What am I missing, here?