Search code examples
javaprintingzebra-printers

How to print an image on Zebra Card printer from Java


I would like to print an image on a zebra card printer from java, the image is of the correct card size. But I would like to know how to position it on the card, so that there will be no margins and it will be printed as if it is being printed from a normal word file, or an image.


Solution

  • In the end I printed it using java without any zebra libraries. but i had to change the pageformat using this way:

            PageFormat defaultPage = printJob.defaultPage();
    
            Paper x = new Paper();
            x.setImageableArea(0, 0, height, width);
            x.setSize(height, width);
            defaultPage.setPaper(x);
            PageFormat pageFormat = defaultPage;
            printJob.setPrintable(this, pageFormat);
    

    the trick was to make a new paper not modify the paper taken from the pageformat.