title: ItextSharp MVC5 C# - text in front of existing pdf
body: <p>I'm building a web app for editing PDF files using iTextSharp.</p>
  
  <p>When I try to write to the PDF, the text is getting printed behind an existing content, however I need to print it on top of it.</p>
  
  <p>Can someone explain to me how can I set a depth property for my text?</p>
  
  <p>This is my code </p>
  
  <pre><code>using (var reader = new PdfReader(oldFile))
  {
      using (var fileStream = new FileStream(newFile, FileMode.Create, FileAccess.Write))
      {
          var document = new Document(reader.GetPageSizeWithRotation(1));
          var writer = PdfWriter.GetInstance(document, fileStream);
  
          document.Open();
  
          try
          {
              PdfContentByte cb = writer.DirectContent;
  
              cb.BeginText();
              try
              {
                  cb.SetFontAndSize(BaseFont.CreateFont(), 12);
                  cb.SetTextMatrix(10, 100);
                  cb.ShowText("Customer Name");
              }
              finally
              {
                  cb.EndText();
              }
  
              PdfImportedPage page = writer.GetImportedPage(reader, 1);
              cb.AddTemplate(page, 0, 0);
  
          }
          finally
          {
              document.Close();
              writer.Close();
              reader.Close();
          }
      }
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/Oen2i.jpg" alt="This how the pdf looks like, one word is behind the table"></p>