PDF with Digital Signature and Certificate causing error

Hi,

I have a C# web application that pulls multiple PDF documents from a database, stored as image files, and stitches them into one big PDF document that is created in memory and displayed in the browser. Some of the PDF documents stored in the database are digitally signed and certified and when the application attempts to stitch them into the overall document the following error is thrown:

Message: Specified method is not supported.
Stack Trace: at ..() at .…ctor(? , ? ) at .?.() at .?.?( , ? ) at .?..( , ?& ) at ..( , ?& ) at ..?(Int64 , ArrayList ) at ..?() at .…ctor(Stream , String , Boolean ) at .…ctor(Stream ) at ..?(Stream ) at Aspose.Pdf.Document.?(Stream , String )

Here is the code that causes the error - it occurs in the 2nd line, when the stream is used to create a document:

// put the DOC byte array into a MemoryStream
System.IO.Stream pdfStream = new System.IO.MemoryStream(pdfImageFileFromDb);

// use the MemoryStream containing a PDF file to create a Words.Document
Aspose.Pdf.Document tempDocument = new Aspose.Pdf.Document(pdfStream);

Is there another way or better way to do this? Can I stitch a digitally signed and certified PDF document from a database into a new pdf document to display in a browser?

Thanks,
Tom

Hi Tom,

Thank you for the details.

However, to test your issue, we would request you to extract a PDF file from your database and share with us. We will check the issue and get back to you.

Sorry for the inconvenience,

Hi Nausherwan,

Thank you for your quick response. Unfortunately, for legal reasons, I cannot send you one of these documents. The documents are university transcripts, which are protected in the US by the Family Educational Rights and Privacy Act (FERPA). Multiple major universities use digital signatures with a certificate issued by GlobalSign CA for Adobe in order to prevent altering of the document.

Since I cannot send you an example for you to test, what I would like to know - is there a best practice for dealing with this type of document - digitally signed and certified - in the manner which I described previously? What is the best way to pull this type of document from a database and add it to existing PDF document in memory to display in a browser? Is there an issue with digitally signed and certified PDFs that would prevent me from being able to do this? Is it because this document is locked, that I cannot append it to another PDF?

Thanks for your help.

-Tom

Hi Tom,

If possible, could you please create a sample file similar to your confidential file with dummy data and share with us. This will help in identifying the cause of the issue soon.

tomq: is there a best practice for dealing with this type of document - digitally signed and certified - in the manner which I described previously? What is the best way to pull this type of document from a database and add it to existing PDF document in memory to display in a browser?

Well, as you are getting the issue while opening the document (in Document object constructor) which is our normal /best practice to open PDF files, I am not sure what could be causing such a problem unless we can reproduce the issue. Regarding displaying the document in a browser, do you need to open the file in some control or just open using Adobe Reader (or some other PDF viewer) to open it in browser? Please share some details with us regarding your requirement.

Also, if possible, you can send us the document via email (you may black out the confidential information. If you can proceed with this, please follow the steps mentioned in the below link and share the template file with us.

[Contact - About - aspose.com]

tomq: Is there an issue with digitally signed and certified PDFs that would prevent me from being able to do this?

Well, there is no issue in opening digitally signed documents using the Document class. Again, unless we get some sample, we won’t be able to identify what is causing the problem.

tomq: Is it because this document is locked, that I cannot append it to another PDF?

What do you mean by “this document is locked”. Please share some details.

Also, could you provide some more details regarding “pulls multiple PDF documents from a database, stored as image files” as per your initial post?

We are sorry for the inconvenience caused.

When I stated that the document is locked, I mean that it is encrypted with a certificate issued by GlobalSign CA for Adobe and it cannot be altered in any way. I have attached a screenshot of what the signature looks like.


What I am wondering is - can I append/concatenate a PDF that has been signed and encrypted with a certificate to another PDF?

Thanks,
Tom

Hi Tom,

Thank you for the details.

Well, if the PDF file is encrypted and does not allow modifications, then you will not be able to open / append any file without a valid password and rights to change the contents of the file (if you have the password, you can use the overloaded constructor of the document class which asks for a password as a parameter). You can check the details of the security applied to your document by viewing its Security tab. You can check that under the Document Properties window. I have attached the screenshot for your reference.

Please do let us know in case you need any further assistance.

Thank You & Best Regards,

Thanks Nausherwan for clarifying that for me.The Document Security tab for the transcript document looks the same as your example, except that printing is allowed. So, that answers my question which leads to another question.


From reviewing other posts on this forum, I discovered that you can detect if a document is encrypted, using the PdfFileInfo class, which contains a boolean property called IsEncrypted. In the case of my application, the Pdf is stored in a SQL database as an image datatype. I pull the Pdf from the database as a byte array in C# and instantiate a Stream class with it. The stream is then used to instantiate a PdfFileInfo class as follows:

System.IO.Stream pdfStream = new System.IO.MemoryStream(pdfAsByteArray);
Aspose.Pdf.Facades.PdfFileInfo fileInfo = new Aspose.Pdf.Facades.PdfFileInfo(pdfStream);

In my application, when the PdfFileInfo class is created, the following error is thrown:
PdfFileInfo is not initialized. Use constructors with parameters or properties for initialization. (Reason: Specified method is not supported.)

My question is - does the encryption/security of the document prevent me from initialing the PdfFileInfo class or is there another way I should be doing this?

Thanks,
Tom

Hi Tom,

Thank you for the details.

I am able to reproduce your mentioned issue after an initial test (using a test file encrypted using certificate). Your issue has been registered in our issue tracking system with issue id: PDFNEWNET-34568. Our development team will further investigate the issue. We will notify you via this forum thread regarding any update.

Sorry for the inconvenience,

The issues you have reported earlier (filed as PDFNEWNET-34568) have been fixed in Aspose.Pdf for .NET 8.4.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.