title: Adding text to a PDF file from a text file
body: <p>This is my code:</p>
  
  <pre><code>        using (FileStream msReport = new FileStream(pdfPath, FileMode.Create))
          {
              //step 1
              using (Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 140f, 10f))
              {
                  try
                  {
                      // step 2.
                      StreamReader sr = new StreamReader("TextFile.txt");
                      string line;
                      PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDoc, msReport);
                      pdfWriter.PageEvent = new ITextEvents();
  
                      //open the stream 
                      pdfDoc.Open();
  
                      for (int i = 0; i &lt; 100; i++)
                      {
                          if ((line = sr.ReadLine()) != null)
                          {
                              Paragraph para = new Paragraph(line, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6));
  
                              para.Alignment = Element.ALIGN_LEFT;
  
                              pdfDoc.Add(para);
  
                              //pdfDoc.NewPage();
                          }
                      }
                      sr.Close();
                      pdfDoc.Close();
  </code></pre>
  
  <p>and it's working...It reads the text file that is in my computer and adds it to PDF... The problem is - it doesn't keep the formatting from the text file. It just adds text. And I need to keep it the way it is. Is there any way to keep the formatting of the text? Can I somehow add it to a table and format the table, or something like that?  </p>