title: Why ITextSharp takes long time to create pdf?
body: <p>my application first load the text file in richtextbox whitout any problem :</p>
  
  <pre><code>        StreamReader str = new StreamReader("C:\\test.txt");
  
          while (str.Peek() != -1)
          {
  
              richtextbox1.AppendText(str.ReadToEnd());
          }
  </code></pre>
  
  <p>after that , i want to export the text of richtextbox to pdf format using itextsharp :</p>
  
  <pre><code>      iTextSharp.text.Document doc = new iTextSharp.text.Document();
          iTextSharp.text.pdf.PdfWriter.GetInstance(doc, new FileStream(filename,        FileMode.Create));
          doc.Open();
          doc.Add(new iTextSharp.text.Paragraph(richtextbox1.Text));
          doc.Close();
  </code></pre>
  
  <p>i have used backgroundworker but it did not help me :</p>
  
  <pre><code>     private delegate void upme(string filenamed);
  
     private void callpdf(string filename)
      {
          iTextSharp.text.Document doc = new iTextSharp.text.Document();
          iTextSharp.text.pdf.PdfWriter.GetInstance(doc, new FileStream(filename, FileMode.Create));
          doc.Open();
          doc.Add(new iTextSharp.text.Paragraph(richtextbox1.Text));
          doc.Close();
      }
  
      private void savepdfformat(string filenames)
   {
       BackgroundWorker bg = new BackgroundWorker();
  
       bg.DoWork += delegate(object s, DoWorkEventArgs args)
       {
          upme movv = new upme(callpdf);
  
          richtextbox1.Dispatcher.Invoke(movv, System.Windows.Threading.DispatcherPriority.Normal, filenames);
  
       };
       bg.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args)
       {
           MessageBox.Show("done");
       };
  
       bg.RunWorkerAsync();   
  }
  </code></pre>
  
  <p>the test.txt is about 2 mb size , it loads very fast in richtextbox1 but when i want to </p>
  
  <p>convert it to pdf, it takes very time and the application hangs.</p>
  
  <p>what should i do for optimization?</p>
  
  <p>thanks for any help.</p>