You can simply draw text overlay on the barcode image. If you generate 1D barcodes such as (code 39, code 128, etc.), then the barcode changes its width based on the input value, but the height is a constant value.
So, you can simply calculate the Y coordinate and X coordinate for the text and draw the text with this code ( based on the code from this answer ):
RectangleF rectf = new RectangleF(70, BarCodeBottom, 90, 50); Graphics g = Graphics.FromImage(BarCodeImage); // set text drawing modes for the high quality look g.SmoothingMode = SmoothingMode.AntiAlias; g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.PixelOffsetMode = PixelOffsetMode.HighQuality; g.DrawString("some barcode caption text", new Font("Tahoma",8), Brushes.Black, rectf); g.Flush();
or you can use some commercial components that automatically calculate the text position (but you can better use your own code if you already rely on iTextsharp).
Disclaimer: I work for ByteScout, the Bytecode creator of the BarCode Generator SDK .
Eugene M Feb 16 '15 at 11:10 2015-02-16 11:10
source share