Quantcast

create barcode as an image

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

create barcode as an image

Ahmet Kilic
I am newbie. I searched on the the forum but I could not found the answer.
My problem is;
I can save barcode  as  an image  but I want to show also the barcode numbers on the picture.
How can I do it?


My code is;

package barcode;

import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import com.lowagie.text.pdf.BarcodeEAN;

public class ImgTest {

    public static void main(String[] args) throws Exception
        {
                BarcodeEAN codeEAN = new BarcodeEAN();
                codeEAN.setCodeType(codeEAN.EAN13);
                codeEAN.setCode("4902555131719");
//                String value = codeEAN.getCode();
//                System.out.println(value);       // I want to show this code on the picture
//                codeEAN.setAltText(value);
                Image image = codeEAN.createAwtImage(Color.black, Color.white);

                BufferedImage bffImg
                        = new BufferedImage(image.getWidth(null),image.getHeight(null), BufferedImage.TYPE_3BYTE_BGR);
                Graphics offg = bffImg.createGraphics();
                offg.drawImage(image, 0, 0, null);

                ImageIO.write(bffImg, "jpeg", new File("test.jpg"));
        }
}

please  help me..
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: create barcode as an image

Paulo Soares-3
You'll have to add the numbers yourself. If you want to create awt images of
barcodes you're better served with
http://sourceforge.net/projects/barbecue/.

Paulo

----- Original Message -----
From: "Ahmet Kilic" <[hidden email]>
To: <[hidden email]>
Sent: Friday, August 14, 2009 8:52 AM
Subject: [iText-questions] create barcode as an image



I am newbie. I searched on the the forum but I could not found the answer.
My problem is;
I can save barcode  as  an image  but I want to show also the barcode
numbers on the picture.
How can I do it?


My code is;

package barcode;

import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import com.lowagie.text.pdf.BarcodeEAN;

public class ImgTest {

    public static void main(String[] args) throws Exception
{
BarcodeEAN codeEAN = new BarcodeEAN();
codeEAN.setCodeType(codeEAN.EAN13);
codeEAN.setCode("4902555131719");
//                String value = codeEAN.getCode();
//                System.out.println(value);       // I want to show this
code on the picture
//                codeEAN.setAltText(value);
Image image = codeEAN.createAwtImage(Color.black, Color.white);

BufferedImage bffImg
= new BufferedImage(image.getWidth(null),image.getHeight(null),
BufferedImage.TYPE_3BYTE_BGR);
Graphics offg = bffImg.createGraphics();
offg.drawImage(image, 0, 0, null);

ImageIO.write(bffImg, "jpeg", new File("test.jpg"));
}
}

please  help me..


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: create barcode as an image

Ahmet Kilic
Thank you very much.
I will try it.

Paulo Soares-3 wrote
You'll have to add the numbers yourself. If you want to create awt images of
barcodes you're better served with
http://sourceforge.net/projects/barbecue/.

Paulo

----- Original Message -----
From: "Ahmet Kilic" <ahmedkilic@gmail.com>
To: <itext-questions@lists.sourceforge.net>
Sent: Friday, August 14, 2009 8:52 AM
Subject: [iText-questions] create barcode as an image



I am newbie. I searched on the the forum but I could not found the answer.
My problem is;
I can save barcode  as  an image  but I want to show also the barcode
numbers on the picture.
How can I do it?


My code is;

package barcode;

import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import com.lowagie.text.pdf.BarcodeEAN;

public class ImgTest {

    public static void main(String[] args) throws Exception
{
BarcodeEAN codeEAN = new BarcodeEAN();
codeEAN.setCodeType(codeEAN.EAN13);
codeEAN.setCode("4902555131719");
//                String value = codeEAN.getCode();
//                System.out.println(value);       // I want to show this
code on the picture
//                codeEAN.setAltText(value);
Image image = codeEAN.createAwtImage(Color.black, Color.white);

BufferedImage bffImg
= new BufferedImage(image.getWidth(null),image.getHeight(null),
BufferedImage.TYPE_3BYTE_BGR);
Graphics offg = bffImg.createGraphics();
offg.drawImage(image, 0, 0, null);

ImageIO.write(bffImg, "jpeg", new File("test.jpg"));
}
}

please  help me..


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: create barcode as an image

xiaoyuandlg
This post has NOT been accepted by the mailing list yet.
In reply to this post by Ahmet Kilic
I am afraid that I am in a similar situation like you described. This also makes me remember the issue on a java barcode generator I've met before.
Loading...