Trying to print from a JTextArea
I am tring to print from a JTextArea. I don't really need to display the JTextArea, just using it to get at the print() function that exists.
I have set the content type to text/html send it some HTML text. When I do print it, the text comes out very large (what shoudl be a 7 page document comes out as 14 pages)
I have tried to change the font, with the setFont I have tried putting something in the HTML to change the font, it seams as the print function ignores the font and uses the default (over large) font.
Is there a call I am missing to apply the font size. etc..
Basicly assume code that follows the kind of logic below as
Code:
public void printText(String htmlCodedText)
{
JTextArea textToPrint = new JTextArea();
textToPrint.setContextType("text/html");
textToPrint.setText(htmlCodedText);
// here I have tried
// textToPrint.setFont(text.getFontName(),Font.NORMAL,text.getFontSize()/2);
try
{
textToPrint.print();
}
catch(/*the exceptions)
{
//handle it
}
}
Also when doing headers and footers and I try to add newlines. It does not put the new lines in headers or footers, I have tested with system.out.printlns and the new lines were there but when sending them to the print fuction it seams it strips the new lines out of it, and prints them all on 1 line.