We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Specified cast is not valid

We use PDF.Kit to stamp PDF documents uploaded to our site. Attempting to stamp the attached file throws a "Specified cast is not valid." exception. The Code is as follows:

Public Sub AppendTimeStamp(ByVal sOutPutFile As String, ByVal sDateFiled As String)
Dim license As Aspose.Pdf.Kit.License = New Aspose.Pdf.Kit.License
Dim sOutFile As String = System.IO.Path.Combine(ConfigurationSettings.AppSettings("TempFiles"), sOutPutFile & "_Stamped.pdf")
Dim sInFile As String = System.IO.Path.Combine(ConfigurationSettings.AppSettings("TempFiles"), sOutPutFile & "_PreStamped.pdf")
Dim Stamper As PdfFileStamp, FileStamp As Stamp = New Stamp
Dim sFiledText As FormattedText

sFiledText = New FormattedText("Filed " & sDateFiled & " ET Office of the Judges of Compensation Claims.", _New FontColor(0, 0, 200), FontStyle.HelveticaBoldOblique, EncodingType.Winansi, True, 10)

Stamper = New PdfFileStamp(sInFile, sOutFile)
FileStamp.IsBackground = False
FileStamp.Pages = New Integer() {1}
FileStamp.SetOrigin(75, 10)

End Sub

Where sOutPutFile = 0999999_07003432_354_10292008_10321868_e
and sDateFiled = 10/29/2008 at 10:32:18 AM.

The error occurs on the line Stamper.Close()

Thanks in Advance

Hello Russ,

I have tested the issue and I’m able to reproduce the same problem. I have logged it in our issue tracking system as PDFKITNET-6321. We will investigate this issue in detail and will keep you updated on the status of a correction. We apologize for your inconvenience.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

The issues you have found earlier (filed as 6321) have been fixed in this update.