I have an JTextArea with some lines of text in it.I want to print that lines of text, here i am using the method getText() and storing the whole data into a string variable. I am passing that string to the print class. while printing that string, text is printed without any spaces, new line or tabs etc. can any one help me by solving my problem.
My printing code
public int print(Graphics g, PageFormat pf, int page) throws PrinterException
{
if (page > 0)
{
return NO_SUCH_PAGE;
}
Graphics2D g2d = (Graphics2D)g;
g2d.translate(pf.getImageableX(), pf.getImageableY());
g.drawString(data,10,10);
return PAGE_EXISTS;
}
Here data is my string variable.
thank u...
I would call it this way