This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hi! Is there an easy way to print a html document, that is displayed in a JEditorPane using the HTMLEditorKit. The document contains multiple pages. But there are no graphics, just formatted Text (bold, different fontsize,...) and horizontal lines. Thanks a lot, Dirk Here comes the code: import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import java.io.*; import java.net.*; import javax.swing.text.*; import javax.swing.text.html.*; import java.awt.print.*;
/* //Initialisierung aus Datei seturl("test.html");
try { editorPane.setPage(url); } catch (IOException e) { System.err.println("Attempted to read a bad URL: " + url); }
*/
}
public void actionPerformed(ActionEvent e) { if (e.getSource()==schliessen) { dispose(); System.exit(0); } if (e.getSource()==speichern) { createFile(); } if (e.getSource()==drucken) { //IS THIS THE RIGHT WAY, OR IS THERE ANY EASIER WAY??? PrinterJob pj=PrinterJob.getPrinterJob(); pj.setPrintable(this); pj.printDialog(); try{ pj.print(); } catch (Exception PrintE) {System.err.println(PrintE.toString());}
} }
public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException { //??? return NO_SUCH_PAGE; }