Thank you for the response. Yes my Pdf stream is from Reporting Services. I get it as a byte array and converted it to a stream and did what you suggested. However the outputstream is always empty. What am I doing wrong?
Public Function Test(ByVal arrBytes() As Byte) As Byte()
Dim msInputStream As MemoryStream = New MemoryStream(arrBytes, True)
Dim msOutputStream As MemoryStream = New MemoryStream()
Try
Dim stamper As PdfFileStamp = New PdfFileStamp(msInputStream, msOutputStream)
Dim stamp As Stamp = New Stamp()
stamp.BindLogo(New FormattedText("This is a test"))
stamp.IsBackground = False
stamp.Rotation = 30
stamp.SetOrigin(100, 100)
stamper.AddStamp(stamp)
arrBytes = GetStreamAsByteArray(msOutputStream)
msInputStream.Close()
msOutputStream.Close()
stamper.Close()
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Return arrBytes
End Function
Private Function GetStreamAsByteArray(ByVal stream As System.IO.Stream) As Byte()
Dim streamLength As Integer = Convert.ToInt32(stream.Length)
Dim fileData As Byte() = New Byte(streamLength) {}
' Read the file into a byte array
stream.Read(fileData, 0, streamLength)
stream.Close()
Return fileData
End Function
End Class