I am preparing an acceptance testing tool for java web start application. That app autoprints pdfs to system-installed printers and I want to verify if produced pdfs are correct. To do this I am looking for a way to mock printing.
I found a way to register a custom printing service before the test:
PrintServiceLookup.registerServiceProvider(fakePrinterService);
And I know how to select that fake printer service in my tested application.
Unfortuately I found no implementations of javax.print.StreamPrintService
that I can use to print to a file except of sun.print.PSStreamPrintService
, which prints to postscript. It also seems to be a part of internals of the JDK, not a public API. Works but leaves some doubts.
Are there any other java printers implementations? It would be best if it could print a pdf.
If not I guess I will go with PSStreamPrintService
and ps2pdf conversion.