How to resize barcode

sventevit picture sventevit · Apr 11, 2011 · Viewed 9.6k times · Source

I'm using iTextSharp to create Code 39. How can I change the size of the code? I can change only the height of the code (via BarHeight property) but not the width.

My code:

Barcode39 code = new Barcode39();
code.Code = content;
code.Baseline = 20;   // Doesn't affect rendering.
code.Size = 20;       // Doesn't affect rendering.
code.BarHeight = 60;  // DOES affect rendering.
Image img = code.CreateDrawingImage(Color.Black, Color.White);

I could resize the image, but I fear that the resolution of the image would suffer.

Answer

kuujinbo picture kuujinbo · Apr 11, 2011

try changing the individual bar widths:

Barcode39 bc39  = new Barcode39();
bc39.Code = "1234";
bc39.X = 2;

Barcode39 inherits from Barcode, which has the Java method setX(), or the X property in .NET.