How to resize barcode
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.
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.
I think the only way that you're going to be able to resize it is to scale the resulting image. The image is a vector image so you don't have to worry about quality although you should make sure to read up on the width rules at various printed sizes. Scaling the image will unfortunately also scale the text portion so you might have to set bc39.AltText
to an empty string and manually draw the text on.
精彩评论