Question

In my java code I'm generating Code 39 with itextpdf in de facto standard way:

Barcode39 code39 = new Barcode39();
code39.setCode(getMySuperDuperCodeInStringRepresentation());
code39.setFont(null);
code39.setBarHeight(Utilities.millimetersToPoints(13f));
code39.setExtended(true);
Image image = Image.getInstance(code39.createAwtImage(Color.BLACK, Color.WHITE), null);

Due documentation for Code 39 "the width ratio between narrow and wide lines can be chosen between 1:2 and 1:3". Is there a way how to set with of the narrow line and aspect ratio? Or this is beyond the scope of Barcode class in itextpdf and I need to use another library for generating barcodes?

Thanks.

Was it helpful?

Solution

After some elaboration, I will answer myself: it's so easy...

Just scale generated Image object:

image.scalePercent(__your_scale_in_percent__);

There is more scaling methods, check docu at: http://api.itextpdf.com/itext/com/itextpdf/text/Image.html

Just be careful for aspect ratio between wide and narrow lines in barcode and it will work well.

OTHER TIPS

The ISO/IEC 16388 Code 39 Specification points out a valid "Wide/narrow ratio" of 2:1 to 3:1.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top