title: how to keep the same format on pdf after write in another one
body: <p>My code Read the text from Pdf and write it in another Pdf with some modifications ,, but the format is not the same in the second Pdf ,,, so how can I keep the same format and style ?</p>
  
  <p>my code is :</p>
  
  <pre><code>string newFile = @"D:\Result.pdf";
              string file = @"D:\Source.pdf";
  
              string imagepath = @"D:\logo.jpg";
              Console.WriteLine("Welcome");
  
              string content="";
              // open the reader
              PdfReader reader = new PdfReader(file);
              iTextSharp.text.Rectangle size = reader.GetPageSizeWithRotation(1);
              Document document = new Document(size);
  
              FileStream fs = new FileStream(newFile, FileMode.Create, FileAccess.Write);
              PdfWriter writer = PdfWriter.GetInstance(document, fs);
  
              int n = reader.NumberOfPages;
  
              bool addimage = false;
              if (!File.Exists(file))
              {
                  file = Path.GetFullPath(file);
                  if (!File.Exists(file))
                  {
                      Console.WriteLine("Please give in the path to the PDF file.");
                  }
              }
              document.Open();
              for (int i = 1; i &lt; n; i++)
              {
                  while (addimage == false)
                  {
                      iTextSharp.text.Image pic = iTextSharp.text.Image.GetInstance(imagepath);
                      pic.ScaleToFit(100f, 100f);
                      //pic.ScalePercent(24f);
                      pic.SetAbsolutePosition(document.PageSize.Width - 100f - 100f, document.PageSize.Height + 100f - 225f);
                      document.Add(pic);
                      addimage = true;
                  }
                  content=PdfTextExtractor.GetTextFromPage(reader, i);
                  document.Add(new Paragraph(content));
                  PdfContentByte cb = writer.DirectContent;
                  cb.MoveTo(document.PageSize.Width / 2, document.PageSize.Height / 2);
                  cb.LineTo(document.PageSize.Width / 2, document.PageSize.Height);
                  cb.Stroke();
              }
              document.Close(); 
          }
  </code></pre>