Java printjob is not printing anything after creating Jar and exe created with Launch4j

72 views Asked by At

Java printjob is working in eclipse but when we convert the application into exe everything works proper except PrintJob. Can anyone support me? Note: Using Windows 7

public static void print() {

        PdfDocument pdf = new PdfDocument();
        pdf.loadFromFile("C:\\Mayura\\KFF Titrator Report.pdf");

        PrinterJob loPrinterJob = PrinterJob.getPrinterJob();
        PageFormat loPageFormat  = loPrinterJob.defaultPage();
        Paper loPaper = loPageFormat.getPaper();

        //remove the default printing margins
        loPaper.setImageableArea(0,0,loPageFormat.getWidth(),loPageFormat.getHeight());

        loPageFormat.setPaper(loPaper);
        loPrinterJob.setPrintable(pdf,loPageFormat);

        //display the print dialog
        if (loPrinterJob.printDialog()) {
            try {
                loPrinterJob.print();
            } catch (PrinterException e) {
                e.printStackTrace();
            }
        }
    }
0

There are 0 answers