Hello all. Of course, this is an urgent request...(could it possibly be otherwise??) :)
The code below worked without issue under the Aspose.pdf.kit
after upgrading to aspose.pdf 6.4.2 we get the 'File is Damaged' problem in almost 80% of our pdf documents.
If System.IO.File.Exists(MyPDFUrl) Then
MyPageCount = Me.DetermineNumberOfPages(MyPDFUrl)
MyFileStream = New FileStream(MyPDFUrl, FileMode.Open, FileAccess.Read, FileShare.Read)
MyOutStream = New MemoryStream
MyMender = New Aspose.Pdf.Facades.PdfFileMend(MyFileStream, MyOutStream)
MyPDFText = Me.BuildUserSignature(GuestKeyIn)
For MyPage As Integer = 1 To MyPageCount
MyMender.AddText(MyPDFText, MyPage, MyLowerX, MyLowerY)
Next
Else
Throw New System.IO.FileNotFoundException("File not found", MyPDFUrl)
End If
the above code is used to build the memory stram in one method and is used in another method here:
If MyPDFStream IsNot Nothing Then
ContextIn.Response.AddHeader("content-disposition", If(PDFInSameWindow, "inline;", "attachment") & " filename=" & Me.CreatePDFFileName(MediaItemIn))
ContextIn.Response.ContentType = "application/pdf"
ContextIn.Response.AppendHeader("Accept-Ranges", "none")
ContextIn.Response.BinaryWrite(MyPDFStream.GetBuffer())
MyPDFStream.Flush()
ContextIn.Response.Flush()
HttpContext.Current.ApplicationInstance.CompleteRequest()
Else
Throw New Exception("MediaItemIn did not produce a PDF MemoryStream from BuildWaterMarkedPDFStream")
End If