mardi 22 mars 2016

Issue while printing label

I'm trying to print a sticker and report for a pharmacy since 2 months ago , this pharmacy has 2 printers, i used an interface called Printable I have used it for printing on A4 size and it works fine! , my problem is when I'm trying to print a sticker , it became too huge !, my label size is 5*3
Here is what i did

  1. wrote some words in the pharmacy image using Graphics2D

  2. Pulled the image to java again

3.sent it to Printable after converting it to Graphics.

  public static void sendToPrinter(BufferedImage bufferdImage) {
    PrinterJob printJob = PrinterJob.getPrinterJob();
    printJob.setPrintable(new Printable() {
        public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
            if (pageIndex != 0) {
                return NO_SUCH_PAGE;
            }
            graphics.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null);

            return PAGE_EXISTS;
        }
    });
    try {
        printJob.print();
    } catch (PrinterException e1) {
        e1.printStackTrace();
    }

Can i control the size of this label ? Btw my image has 200 DPI and i know the printable print with 72 DPI, But i have no idea what should i do. The printer name is seewoo lb40 Please i need a solution. Regards.



Issue while printing label

Aucun commentaire:

Enregistrer un commentaire