2

I created a QRCode barcode in iText and I want to save this file to disk. It appears to create a ImgCCITT type. It saves down to the disk but the file is corrupted. I also tried to save it as .jpg. Any ideas of how to save an uncorrupted barcode image to disk.

BarcodeQRCode qrcode = new BarcodeQRCode("292035-1", 4, 4, null);
Image qrImg = qrcode.getImage();

qrImg.setUrl(new URL("...images/" + i + ".CCITT"));

OutputStream out1 = new FileOutputStream("C:/Program Files (x86)/images/" + i + ".CCITT");
out1.write(qrImg.getRawData());
out1.flush();
out1.close();

What I'm trying to do is use velocity templates to create html passing java objects but having an issue with passing a 128 and QRcode barcode image from jav.a

To get around it I thought of saving it to disk, setting the url and getting that back in the velocity template, but the saved file seems to be corrupted.

Velocity Template:

 <img src="${qrcode.getUrl()}"/>       

Thanks, Martin

4

0 回答 0