Hi,
I am able to display the barcode39 image in JSP. I need to display the text also below the image which i am not able to do. Please help me.
I am using iText to generate the barcode. iText has 2 options to create barcode39. createImageWithBarcode and createAwtImage.
createImageWithBarcode comes with text below the barcode by default. But i am unable to convert this iText Image type to any other image like java.awt.Image or BufferedImage. And also i am not able to write this image to JSP. If there is way to convert the image or display it as it is on JSP then it solves my problem. Please let me know is there any way.
I had to use createAwtImage method to get image. This atleast i am able to display image on JSP. But in this case i am not able to display text under barcode.
for the createAwtImage My servlet code is:
Barcode39 codeEAN = new Barcode39();
codeEAN.setBarHeight(100);
codeEAN.setSize(500);
codeEAN.setCode("123456789");
Image img = codeEAN.createAwtImage(Color.BLACK, Color.WHITE);
BufferedImage bi = new BufferedImage(img.getWidth(null), img
.getHeight(null), BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = bi.createGraphics();
g2d.drawImage(img, 0, 0, null);
response.setContentType("image/png");
final OutputStream outputStream = response.getOutputStream();
ImageIO.write(bi, "png", outputStream);
outputStream.close();
If i get solution for any one i will be very happy. Please let me know if there are any pointers.
Thanks
Mahesh