iTextSharp를 사용하여 Microsoft 보고서 뷰어의 여러 pdfs를 함께 사용합니다. 아래 코드의 page.AddImage (image__1)가 오류를 던지고 있습니다. 객체 참조가 객체의 인스턴스로 설정되지 않았습니다. 나는 아무것도 보이지 않는다. 보고서 뷰어에서 보고서에 참여하고 워터 마크 이미지를 추가 할 수있는 다른 방법이 있습니까?PDF 문서에 이미지를 추가하는 방법은 무엇입니까?
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 < 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
가능한 복제본 [기존 PDF에 iTextSharp로 이미지를 삽입하려면 어떻게해야합니까?] (http://stackoverflow.com/questions/583629/how-can-i-insert-an-image-with-itextsharp- in-a-existing-pdf) –