Reputation: 7302
I have a Java application, which communicates to a printer and prints documents. Till now I needed only PS/PDF and the printer could handle that. However, now I need to print HTML documents also.
I have seen that it is possible to do it using JavaFX (WebView), but the server on which the application runs does not have a display. Hence, I cannot render it to a display object (in Swing or AWT). What are my options to get a PostScript rendering of a web page which I can then send to the printer?
One solution I had was to use xvfb to emulate
a display screen, but that not only seems far fetched, but also is impossible for us to maintain as we use cloud services and our current CI framework does not handle management of system-level binaries.
Any help is greatly appreciated.
Upvotes: 0
Views: 901
Reputation: 119
That iText is what I'm using in one of my projects to generate PDF on a server from an HTML page. doc is the HTML Document and output is an OutputStream.
ITextRenderer renderer = new ITextRenderer();
renderer.setDocument(doc, null);
OutputStream output = ec.getResponseOutputStream();
renderer.layout();
renderer.createPDF(output);
Upvotes: 1
Reputation: 12259
As you already have the infrastructure for printing PS/PDF, you can "convert" (render) your HTML into PS; see: what is the best way to convert html to postscript? in java
Upvotes: 0