PdfKitErrorCodeException: File is damaged. Please contact Aspose.Pdf.Kit development team

I get the following error


[PdfKitErrorCodeException: File is damaged. Please contact Aspose.Pdf.Kit development team.]
x30a678191d9b1780.x573da502a3364b6b.x5b81632e5b71b64c(Int32& x1de68a531466236f, Int32& x39b5532b4ddc40a3) +1346
Aspose.Pdf.Kit.PdfConverter.xaf6adc9ec3dfd936() +646
Aspose.Pdf.Kit.PdfConverter.DoConvert() +11
OurNamespace.LinkButtonUpload_Click(Object sender, EventArgs e) +854
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +111
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +79
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

with the following test-code on an ASP.NET webpage

for (int i = 0; i <= 1; i++)
{
var converter = new PdfConverter();
using (var inStream = new MemoryStream(buffer))
{
converter.BindPdf(inStream);
converter.DoConvert();
while (converter.HasNextImage())
{
using (var outStream = new MemoryStream())
{
if (i == 0)
converter.GetNextImage(outStream, System.Drawing.Imaging.ImageFormat.Png, 800f, 800f, 100);
else
converter.GetNextImage(outStream, System.Drawing.Imaging.ImageFormat.Png, 800, 800, 100);

... process outStream ...
}
}
}
}

The conversion process works as expected the first time around.
However it fails on DoConvert the second time around.

If it fails in such a simple scenario, how will it work with multiple simultaneous page impressions 8-O

Any ideas?

Hi Jay,

Please share the input PDF file with us as well. I would like to share with you that sometimes such issues might be caused due to the particular structure or content of the PDF file. We’ll investigate the issue using your particular scenario and provide you a fix accordingly.

We’re sorry for the inconvenience and looking forward to help you out.
Regards,