简体   繁体   中英

Printing dynamically generated server-side HTML through Print Server

What is the easiest way to print dynamically generated HTML through a Java Print Server? Due to restrictions on the project I have to send the HTML string to the printer. I cannot do any file I/O to write to an HTML file and then send the reader to the Print Server. I am also unable to send the data to a JSP and then print the JSP.

In all of my searches online I have found several examples of how to print text from an input reader, but never from a String. What would be the best approach to take?

I have tried looking up plain text and html text doc flavored print services but none of my printers are being returned:

DocFlavor flavor = DocFlavor.STRING.TEXT_PLAIN;
DocFlavor flavor = DocFlavor.STRING.TEXT_HTML;

PS Part of the reason for the requirements is a web-based application needs to print to various types of printers without the print dialog popping up. Any machine that will be running this web app will be set up by us so any settings/permission issues are not a problem.

What about converting the String to an InputStream?

InputStream stream = new ByteArrayInputStream(exampleString.getBytes("UTF-8"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM