I want to print out the contents of a JEditorPane, which contains highlighted text (the colour is set using setCharacterAttributes). However, when I use the most basic print() method, as in:
try {
boolean complete = TextArea.print();
if (complete) {
return;
}
else {
JOptionPane.showMessageDialog(null, "File could not be printed");
}
}
catch (PrinterException ex) {
JOptionPane.showMessageDialog(null, "File could not be printed");
}
the printed document does not look as I expect. Specifically:
- The background of the printed area, but not the margins, is light blue.
- Highlighted text is printed in colour.
- The font-size is quite large (only 6 or 7 words per line). This is specified when the JEditorPane is created - is there any way of using another size when printing?
What I want is black text on a white background. If anyone could point me in the right direction I'd be very grateful!