Free Support Forum - aspose.com

Corrupt PDF after saving

Opening attached original.pdf, and saving it to a new file,
results in many System.Exceptions, that seam to be handled internally by Aspose.

(A first chance exception of type 'System.Exception' occurred in Aspose.Pdf.dll)

The output, is an invalid pdf, 1% the size of the original. (208kb vs. 2kb)

Please let me know what is wrong here; And if possible, please stop handling system exceptions internally or expose a GetLastError method, so we third party developers have a chance of alerting ourselves to these situations, before several of our documents have been corrupted.

Here is some example code, that reproduces the error.:

string filename = "original.pdf";
string workfile = "workfile.pdf";

using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) {
fileInfo = new PdfFileInfo(fs);
using (FileStream fs_out = new FileStream(workfile, FileMode.Create, FileAccess.Write)) {
fileInfo.Save(fs_out);
fs_out.Flush();
fs_out.Close();
}
fs.Close();
}

// Since no errors/exceptions are detected; the original file is overwritten with workfile here...

Just a quick note…

This was tried with Aspose.PDF 10.5 (and 10.1)
Hi there,

Thanks for your inquiry. I have tested your shared code using Aspose.Pdf for .NET 10.6.0 and unable to notice the reported issue. Please download and try latest version of Aspose.Pdf for .NET, it will resolve the issue. If the issue still persist then please share your environment details, so we will investigate the issue further.


jens.churchill:

Please let me know what is wrong here; And if possible, please stop handling system exceptions internally or expose a GetLastError method, so we third party developers have a chance of alerting ourselves to these situations, before several of our documents have been corrupted.


Regarding exception handling, we will appreciate it if you please share some more details about this. So we will investigate the issue and provide you information accordingly.

Best Regards,

I downloaded Aspose.Total, from 2015-07-13.

http://www.aspose.com/community/files/51/.net-components/aspose.total-for-.net/entry228891.aspx

Aspose.PDF is dated 06-04-2015, version 10.5, and produces the error. (and handles internal system.exception)

However, I can see that, downloading aspose.pdf directly, yields a version 10.6 from 2015-07-13.
http://www.aspose.com/community/files/51/.net-components/aspose.pdf-for-.net/entry640936.aspx

This seams to work, and I will test it.

Thank you.

Hi Jens,


Thanks for the acknowledgement.

Aspose.Pdf for .NET 10.6.0 was published yesterday and the time when you downloaded Aspose.Total for .NET (Dll’s), it might not have included the latest release version but as the build process is automatic, if you get the latest copy, you will observe that latest release of Aspose.Pdf for .NET 10.6.0 is included in package.

In case you still face any issue, you can directly download the copy from Aspose.Pdf for .NET 10.6.0 (dll’s).

Should you have any further query, please feel free to contact.