Hi,

My requirement is to display barcode on screen and user can take a print of
that screen.

I am using java and jsp.

I am able to display barcode successfully on screen. But when i take a print
of that and scan it, the barcode is not recognized by the barcode
readers/scanners. If i see the printout closely, i could make out that the
lines of barcode are distorted a bit.

My code is:
Barcode objBarcode = new Barcode39();
objBarcode.setBarHeight(55);
objBarcode.setCode(123456789098765);

Image objImage = objBarcode.createAwtImage(Color.BLACK, Color.WHITE);

BufferedImage objBufferedImage = new BufferedImage(300,
        75, BufferedImage.TRANSLUCENT);

Graphics2D objGraphics2D = objBufferedImage.createGraphics();
objGraphics2D.drawImage(objImage, 0, 0, 300, 55, null);
objGraphics2D.setColor(Color.BLACK);

Font objFont = new Font("monospaced", Font.PLAIN, 12);
objGraphics2D.setFont(objFont);


String strBarcodeText = "* 123456789098765 *";
FontMetrics objFontMetrics = objGraphics2D.getFontMetrics();
Rectangle2D area = objFontMetrics.getStringBounds(strBarcodeText,
        objGraphics2D);
objGraphics2D.drawString(strBarcodeText, (int) (objBufferedImage
        .getWidth() - area.getWidth()) / 2, (int) (objBufferedImage
        .getHeight() - 5));

response.setHeader("Cache-Control", "no-store");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", 0);
response.setContentType("image/png");
final OutputStream outputStream = response.getOutputStream();
ImageIO.write(objBufferedImage, "png", outputStream);
outputStream.flush();
outputStream.close();

Please help me.

I tried open source JBarcodeBean. With this i am able to display barcodes as
the barcode scanners/readers recognize the barcodes generated by
JBarcodeBean.

I would like to get same results with iText also. Please help me.

-- 
Regards...
Mahesh
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to