title: JTextArea Printing
body: <p>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.</p>
  
  <p>My printing code</p>
  
  <pre><code>public int print(Graphics g, PageFormat pf, int page) throws PrinterException 
      {
  
  
          if (page &gt; 0) 
          {                                                                                           
              return NO_SUCH_PAGE;
          }
          Graphics2D g2d = (Graphics2D)g;
          g2d.translate(pf.getImageableX(), pf.getImageableY());
          g.drawString(data,10,10);
          return PAGE_EXISTS;
      }
  </code></pre>
  
  <p>Here data is my string variable.</p>
  
  <p>thank u...</p>