How to print HTML and not the code using Java Print API? -


I have to print an HTML file on a user-defined printer without showing the print dialog I am the code I run below, But it prints the HTML code, not the actual page that is displayed in IE.

  import java.io.File; Import java.net.MalformedURLException; Import java.net.URL; Import javax.print.DocFlavor; Import javax.print.DocPrintJob; Import javax.print.PrintException; Import javax.print.printService; Import javax.print.printServiceLookup; Import javax.print.SimpleDoc; Import javax.print.attribute.HashPrintServiceAttributeSet; Import javax.print.attribute.PrintServiceAttributeSet; Import javax.print.attribute.standard.PrinterName; Public class print {public static zero main (string [] args) throws print exposition {String printerName = "\\\\ network-path \\ myPrinter"; String filename = "c: \\ log \\ myLog.html"; PrintServiceAttributeSet Print ServiceAttributeSet = New HashPrintServiceAttributeSet (); PrintServiceAttributeSet.add (new printer name (printer name, empty)); PrintService [] Print Services = Print Service Lockup. LookupprintServices (blank, printSystemArrbetSat); // List of printers url = null; Try {url = (new file (filename)). ToURI () ToURL (); } Catch (malmarmdureleuxation E) {e.printStackTrace (); } DocFlavor taste = DocFlavor.URL.AUTOSENSE; SimpleDoc doc = New SimpleDoc (url, taste, empty); PrintService printService = Print Services [0]; DocPrintJob printJob = printService.createPrintJob (); If (printService.isDocFlavorSupported (taste)) {tryJob.print (doc, null); } Catch (print option e) {e.printStackTrace (); }} And {new print expansion ("HTML tastes are not supported on this printer"); }}}  

I can print the HTML using the JEditorPane.print () method. But I was thinking that it can be done without the jedrator. Print () Can anyone help? Using the HTML Presentation Engine, you first need to render the HTML and as a result the image must be printed.

"post-text" itemprop = "text">

There are some Java based HTML rendering engines I have not tried to do them myself, so I do not know who to recommend. Google keeps on top of the list

There is a class imageraander in the CSS box that may be necessary for you. "Presents a document and stores the results in a bitmap or vector image" You can print it if you have a bitmap


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -