Hi,
We have some pdfs that have been created by Nuance’s Omnipage from some scanned images.
Before using Aspose.pdf, the pdf’s open fine without any problems.
If we then use Aspose.pdf to add encryption to the pdf’s, the pdf files no longer open, and Acrobat reports an error ‘There was an error opening this document. The file is damaged and could not be repaired.’
Do you know why this is happening?
Many Thanks,
Chris
Just as an update, it appears to be an issue because the pdf is v1.6. Changing it to 1.4 allows aspose.pdf to create a file which isn’t corrupt.
What version of pdf does Aspose.pdf support?
Thanks
Hi Chris,
chrisgdg:
Hi,
We have some pdfs that have been created by Nuance’s Omnipage
from some scanned images.
Before using Aspose.pdf, the pdf’s open fine without any problems.
If we then use Aspose.pdf to add encryption to the pdf’s, the pdf files no longer open, and Acrobat reports an error ‘There was an error opening this document. The file is damaged and could not be repaired.’
Do you know why this is happening?
Many Thanks,
Chris
Thanks for your inquriy. We will appreciate it if you please share your sample document and code here, We will test the scenario and will guide you accordingly.
We are sorry for the inconvenience caused.
Best Regards,
Hi Chris,
chrisgdg:
Just as an update, it appears to be an issue because the pdf is v1.6. Changing it to 1.4 allows aspose.pdf to create a file which isn't corrupt.
What version of pdf does Aspose.pdf support?
Thanks
Thanks for sharing your findings. However please note Aspose.Pdf supports PDF versions 1.3,1.4,1.5,1.6 and 1.7. Please share your sample document and code as requested above, so we will test the scenario and will share our findings with you.
Best Regards,
Hi Tilal,
I have attached one of the pdf files created by Omnipage. It appears that Aspose corrupts it if v1.5, 1.6 or 1.7 is used within Omnipage.
My code is very simple:
using (Aspose.Pdf.Document doc = new Aspose.Pdf.Document(textBox1.Text))
{
doc.Encrypt(“test1”, “test2”, Aspose.Pdf.Permissions.PrintDocument, Aspose.Pdf.CryptoAlgorithm.RC4x40);
doc.Save(“c:\test\ocr\password.pdf”);
}
I’ve tried all 4 CrypteAlgorithms
Many Thanks,
Chris
Hi Chris,
Thanks for sharing the resource file.
I have tested the scenario and I am able to notice the same problem. For the sake of correction, I have logged this problem as PDFNEWNET-39970 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.
However, as workaround, you may consider using Aspose.Pdf for .NET to change PDF file version and then perform encryption. Please try using the following code snippet.
[C#]
using (Aspose.Pdf.Document doc = new Aspose.Pdf.Document("c:/pdftest/bw1.5.pdf"))
{
{
doc.Convert("c:/pdftest/conversionlog.txt",
PdfFormat.v_1_4, ConvertErrorAction.Delete);
doc.Encrypt("test1", "test2", Aspose.Pdf.Permissions.PrintDocument, Aspose.Pdf.CryptoAlgorithm.RC4x40);
doc.Save("c:\\pdftest\\bw1_Encrypted_password.pdf");
}
}
Hi Nayyer,
unfortunately we cant change the code that uses Aspose, as it is a third party component that is calling the Aspose library rather than us directly. Also, I tried this on our test file, and the size went from just over 200kb to 3.2mb, so not a solution for us.
We have also been talking with Nuance about the issue, and they have given some more information on what they believe the issue is:
From PDF version 1.5 there is an opportunity to include
object streams in the PDF. This information answers your question regarding
what new feature was introduced in our v1.5, v1.6, v1.7.
Nevertheless catalog dictionary should not be included in an
object stream. If Adobe Reader faces such a case in a password protected PDF
then it keeps the PDF damaged. Other PDF readers do not keep such PDFs damaged,
and they open it. An example of such is our Power PDF.
It is the Aspose password encryption process that places the
catalog dictionary in an object stream.
I hope this is helpful for you.
Kind Regards,
Chris
The issues you have found earlier (filed as PDFNET-39970) have been fixed in Aspose.PDF for .NET 19.3.