title: Add Image And Text To Existing .pdf Using iText in VB.net
body: <p>I've got the below code on a button click which work great.  It adds an image to each existing .pdf and then combines several of the new .pdf's together and creates one .pdf.  Again, this part of it works great.  </p>
  
  <p>The problem I'm having is now I want to keep the existing code but add some text to each page at the same point in the code where the image gets added.  I've read a bunch of examples on how to add text to an existing .pdf but due to my inexperience in the area I cant figure out how to make any of the examples work with my existing code. Using VB.net.</p>
  
  <p>I want to add a simple line of text "Example Of text" and position it on the page (300, 300).</p>
  
  <p>Any help would greatly appreciated. </p>
  
  <pre><code>    Dim tempFilename = IO.Path.GetTempFileName()
      Dim tempFile As New IO.FileStream(tempFilename, IO.FileMode.Create)
  
      ' Set up iTextSharp document to hold merged PDF
      Dim mergedDocument As New iTextSharp.text.Document(iTextSharp.text.PageSize.LETTER)
      Dim copier As New iTextSharp.text.pdf.PdfCopy(mergedDocument, tempFile)
      mergedDocument.Open()
  
      Dim pic1 As String = "C:\xxx\xxxx\xxx.png"
  
              Using inputPdfStream As IO.Stream = New IO.FileStream(Server.MapPath(".") + "/xxx.pdf", IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
                  Using inputImageStream As IO.Stream = New IO.FileStream(pic1, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
                      Using outputPdfStream As IO.Stream = New IO.FileStream(Server.MapPath(".") + "/xxx2.pdf", IO.FileMode.Create, IO.FileAccess.ReadWrite, IO.FileShare.None)
                          Dim reader1 = New iTextSharp.text.pdf.PdfReader(inputPdfStream)
                          Dim stamper = New iTextSharp.text.pdf.PdfStamper(reader1, outputPdfStream)
                          Dim pdfContentByte = stamper.GetOverContent(1)
  
                          Dim image__1 As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(inputImageStream)
                          image__1.SetAbsolutePosition(527, 710)
                          image__1.ScaleAbsolute(60, 60)
                          pdfContentByte.AddImage(image__1)
                          stamper.Close()
                          reader1.Close()
                          outputPdfStream.Close()
                          inputImageStream.Close()
                          inputPdfStream.Close()
                          outputPdfStream.Dispose()
                      End Using
                  End Using
              End Using
  
              Dim reader As New iTextSharp.text.pdf.PdfReader(New iTextSharp.text.pdf.RandomAccessFileOrArray(Server.MapPath(".") + "/yyy/xxx3".pdf", True), Nothing)
  
              For pageNum = 1 To reader.NumberOfPages
                  copier.AddPage(copier.GetImportedPage(reader, pageNum))
              Next
  
              PTime = PTime + 1
          Loop
  
          mergedDocument.Close()
          tempFile.Dispose()
  </code></pre>