Render Barcode to Printer

Skip to end of metadata
Go to start of metadata
Aspose.BarCode for Java provides graphics interface to render barcode on various situations, including awt graphics, web response streams, printers and image. This section demonstrates how to render barcode to printers. In other words, how to print barcode image directly.
Programming Sample

The following sample shows how to render barcode to printers

[Java]
public class Sample
{
    public void paint(Graphics g) {
    BarCodeBuilder b = this.getBarCodeBuilder();
    //...
    bimg = (BufferedImage) b.generateBarCodeImage();
    int w = bimg.getWidth();
    int h = bimg.getHeight();
    int[] rgb = new int[w * h];
    bimg.getRGB(0, 0, w, h, rgb, 0, w);
    //...
    if (rgb.length > 0) {
        System.out.println("RGB OK.");
    }
    g.drawImage(bimg, 0, 0, this);
    //this.getBarCodeBuilder().render(g);
}
};
 
Output

Here's the runtime snapshot:

Figure: Rendering barcode to printer graphics

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.