I’m using Aspose PDF 9.5.
The following error is thrown on the PdfFileStamp object AddStamp method.
Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
at Aspose.Pdf.Facades.PdfFileStamp.??¶(Stamp , Int32 )
at Aspose.Pdf.Facades.PdfFileStamp.??¶(Stamp )
at ERSClasses.MSDS2.PrintMSDS(Int32 listId) in C:\ers.Projects\Main\ClientInf
ormationSystem\ERSClasses\MSDS2.vb:line 392
The code causing that error is as follows:
Private _objStamp As New Facades.PdfFileStamp
Dim myFileStream As New FileStream(filename, FileMode.Open)
Dim myMemoryStream As New MemoryStream()
_objStamp = New PdfFileStamp(New Document(myFileStream))
_objStamp.Save(myMemoryStream)
Dim myText As New FormattedText()
myText.AddNewLineText(headerText)
Dim myStamp As New Facades.Stamp()
myStamp.BindImage(String.Format("{0}\whitebox.gif", _msdsPathBase))
myStamp.SetOrigin(0, 0)
myStamp.SetImageSize(_objStamp.Document.PageInfo.Width, 20)
_objStamp.AddStamp(myStamp)
_objStamp.Close()
Attached is one of the pdf files that throws the error