Search code examples
javaprintingspool

Java print service API: send job to printer spool?


I am using Java print service API to select PrintService and then pass it to JasperReport's JRPrintServiceExporter. The basic idea is to just send a document to the provided PrintService. It is actually using java.awt.print.PrinterJob.print().

It seems like you cannot send a print job to a printer that has PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS attribute, when it is offline or powered off If I sent a job to it, I would get a PrinterException because it is not accepting jobs.

Is it possible to print to a "NOT_ACCEPTING_JOBS" printer? In actual operating system this works, the job is queued in the pool. How to achieve the same effect using Java print service API?


Solution

  • I think the problem you are trying to solve is similar to this bug. The problem seems to be that Java 1.5 and 1.6 looks at the wrong flags (printer instead of queue).

    A solution that seems to work is to use the ForceAcceptPrintService described in this forum. Alternatively, this post mentions a workaround using byte manipulation but I didn't try that solution myself.