title: How to add an Image to a PDF document?
body: <p>I am using iTextSharp to join multiple pdfs together that are from microsofts report viewer.  page.AddImage(image__1) in the code below is throwing an error Object reference not set to an instance of an object. I am not seeing what is set to nothing. Is there a different way that I can join reports from the report viewer and add a watermark image?</p>
  
  <pre><code>    mybytes = MSRptViewer1.LocalReport.Render("PDF", Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)
      reader = New iTextSharp.text.pdf.PdfReader(mybytes)
      numberOfPages = reader.NumberOfPages
      currentPageNumber = 0
  
      Dim imageFile As String = Server.MapPath("WaterMark.png")
      Dim buffer As Byte() = IO.File.ReadAllBytes(imageFile)
      Dim image__1 As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(buffer)
      image__1.SetAbsolutePosition(100, 100)
  
      Do While (currentPageNumber &lt; numberOfPages)
          currentPageNumber += 1
          doc.SetPageSize(PageSize.LETTER)
          doc.NewPage()
  
          page = writer.GetImportedPage(reader, currentPageNumber)
          page.AddImage(image__1)
  
          rotation = reader.GetPageRotation(currentPageNumber)
          If (rotation = 90) Or (rotation = 270) Then
              cb.AddTemplate(page, 0, -1.0F, 1.0F, 0, 0, reader.GetPageSizeWithRotation(currentPageNumber).Height)
          Else
              cb.AddTemplate(page, 1.0F, 0, 0, 1.0F, 0, 0)
          End If
      Loop
  </code></pre>