I am trying to turn a QR code into an image (for embedding into a PDF). I’ve tried various methods and nothing seems to work. The image is always 33 pixels wide (exactly enough for the the code bits).
In the code below I tried using different units, as well as different sizes, but the image size never changes. How can I get a 2.5 inch image?
getOnlyBarCodeImage() returns a 33 pixel image, and save() saves a 1,914 pixel image…
public static BufferedImage getQrCode2( String text )
{
BarCodeBuilder builder = new BarCodeBuilder();
builder.setSymbologyType( Symbology.QR );
builder.setCodeText( text );
builder.setCodeLocation( CodeLocation.None );
builder.setQRErrorLevel( QRErrorLevel.LevelH );
builder.setGraphicsUnit( GraphicsUnit.Inch );
builder.setImageHeight( 2.5f );
builder.getMargins().set( 0 );
// builder.save( “…path…\QRImageTWO.png” );
return builder.getOnlyBarCodeImage();
}
builder.setCodeText( "123456789" );
builder.setCodeLocation( CodeLocation.None );
builder.setQRErrorLevel( com.aspose.barcode.QRErrorLevel.LevelH );
builder.setGraphicsUnit( com.aspose.barcode.GraphicsUnit.Inch );
builder.setImageHeight( 2.5f );
builder.getMargins().set( 0 );
int width = ObjImg.getWidth();
int height = ObjImg.getHeight();
byte[] pixels = ((java.awt.image.DataBufferByte) ObjImg.getRaster().getDataBuffer()).getData();
Did you check the size of the image you attached - it’s very large (1218 pixels). It should only be 2.5 inches. That varies of course with what “size” means (paper, screen, resolution, etc) but I’m still guessing it’s still too large.
If you change the image height in your code, does it affect the size of your output?
Good to hear. You guys still have some of the best and fastest tech support! Thanks.