title: wpf content print a textbox
body: <p>I am developing a text editor with WPF and have tried the following code to print the contents of a textbox:</p>
  
  <pre><code>PrintDialog pd = new PrintDialog();
  if ((pd.ShowDialog() == true))
  {
      RichTextBox richTB = new RichTextBox();
      richTB.Document.Blocks.Add(new Paragraph(new Run(TBXEditor.Text)));
  
      //use either one of the below      
      pd.PrintVisual(richTB as Visual, "printing as visual");
      pd.PrintDocument((((IDocumentPaginatorSource)richTB.Document).DocumentPaginator), "printing as paginator");
  }
  </code></pre>
  
  <p>It does not work well. If I click the print menu ONCE, I get TWO prints and there is no left margin. The text at the beginning of the line is not printed completely</p>
  
  <p>Does anyone have a better solution?</p>