首页 > 解决方案 > 打印时缺少报告

问题描述

我有一个应用程序,允许用户将文档列表直接发送到打印机。他们可以在屏幕上看到条目列表,当他们单击“打印”时,应用程序会一一创建它们并将它们发送到打印机。它工作得很好,但有时它会遗漏一两个。

我创建了日志以查看发生了什么,但它没有显示任何内容。以下是将文档发送到打印机的方法

public static void print(PDDocument document) throws PrinterException
{
    PrintService printer= findPrinter();

    PrinterJob job = PrinterJob.getPrinterJob();
    job.setPageable(new PDFPageable(document));

    job.setPrintService(printer);
    try {
        job.print();
        logger.info("sent to printer: " + printer.getName());
    }catch (Exception ex){
        logger.info("fail to send to printer: " + printer.getName());
        throw new PrinterException("Report fail to print");
    }
}

今天的日志就是这些。该方法之外还有其他日志来识别打印的报告。上次打印的报告是因为之前的批次中缺少它。但是,它显示为已发送到批次中的打印机。

2020-03-05 11:44:02 INFO  EspFailureServiceManager:74 - sent to printer: \\niabps01\ACC Mono Printer
2020-03-05 11:44:02 INFO  EspFailureServiceManager:102 - This is info:  Report created with batchId 67969  and appId: 323412

2020-03-05 11:44:24 INFO  EspFailureServiceManager:74 - sent to printer: \\niabps01\ACC Mono Printer
2020-03-05 11:44:24 INFO  EspFailureServiceManager:102 - This is info:  Report created with batchId 67971  and appId: 323441

2020-03-05 11:44:50 INFO  EspFailureServiceManager:74 - sent to printer: \\niabps01\ACC Mono Printer
2020-03-05 11:44:50 INFO  EspFailureServiceManager:102 - This is info:  Report created with batchId 67972  and appId: 323688

2020-03-05 11:44:50 INFO  EspFailureServiceManager:108 - This is info: 3 reports have been created

2020-03-05 12:37:47 INFO  EspFailureServiceManager:74 - sent to printer: \\niabps01\ACC Mono Printer
2020-03-05 12:37:47 INFO  EspFailureServiceManager:102 - This is info:  Report created with batchId 67973  and appId: 321932

2020-03-05 12:37:50 INFO  EspFailureServiceManager:74 - sent to printer: \\niabps01\ACC Mono Printer
2020-03-05 12:37:50 INFO  EspFailureServiceManager:102 - This is info:  Report created with batchId 67973  and appId: 321931

2020-03-05 12:37:54 INFO  EspFailureServiceManager:74 - sent to printer: \\niabps01\ACC Mono Printer
2020-03-05 12:37:54 INFO  EspFailureServiceManager:102 - This is info:  Report created with batchId 67973  and appId: 321930

2020-03-05 12:37:56 INFO  EspFailureServiceManager:74 - sent to printer: \\niabps01\ACC Mono Printer
2020-03-05 12:37:56 INFO  EspFailureServiceManager:102 - This is info:  Report created with batchId **67973**  and appId: **321929**

2020-03-05 12:37:59 INFO  EspFailureServiceManager:74 - sent to printer: \\niabps01\ACC Mono Printer
2020-03-05 12:37:59 INFO  EspFailureServiceManager:102 - This is info:  Report created with batchId 67973  and appId: 321933

2020-03-05 12:38:02 INFO  EspFailureServiceManager:74 - sent to printer: \\niabps01\ACC Mono Printer
2020-03-05 12:38:02 INFO  EspFailureServiceManager:102 - This is info:  Report created with batchId 67973  and appId: 321924

2020-03-05 12:38:02 INFO  EspFailureServiceManager:108 - This is info: 6 reports have been created

2020-03-05 12:39:58 INFO  EspFailureServiceManager:74 - sent to printer: \\niabps01\ACC Mono  Printer
2020-03-05 12:39:58 INFO  EspFailureServiceManager:102 - This is info:  Report created with batchId **67973**  and appId: **321929**

2020-03-05 12:39:58 INFO  EspFailureServiceManager:108 - This is info: 1 reports have been created

有人可以帮忙吗?

标签: javaspring-bootitext

解决方案


推荐阅读