java.awt.print.PrinterException:纸张的可成像高度太小

时间:2015-04-23 13:01:51

标签: java printing

我是java的新手并尝试使用以下代码打印pdf文件但是,我一直在进行上述操作。你能帮我解决它吗?

这是我的代码

private void printMergedFile(String printerName, String job, String fileName) throws IOException, PrinterException  
{
    PrintService[] service = PrinterJob.lookupPrintServices(); // list of printers          
    DocPrintJob docPrintJob = null;
    PrinterJob pjob = PrinterJob.getPrinterJob();
    PDDocument doc = PDDocument.load(fileName);

    int count = service.length;

    for (int i = 0; i < count; i++) {
        if (service[i].getName().equalsIgnoreCase(printerName )) {
            docPrintJob = service[i].createPrintJob();
            i = count;
        }
    }


    pjob.setPrintService(docPrintJob.getPrintService());
    pjob.setJobName(job);
    pjob.print();
    doc.silentPrint(pjob);  
}

的Tx

0 个答案:

没有答案