We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Getting "key does not exist" error when saving a PDF

Thread ID:

Created:

Updated:

Platform:

Replies:

142540 Feb 8,2019 09:43 AM UTC Feb 11,2019 09:27 AM UTC ASP.NET MVC - EJ 2 2
loading
Tags: PDF
Charles Southey
Asked On February 8, 2019 09:43 AM UTC

Hi,

We are using the Syncfusion PDF component to assemble externally-source PDF documents into a single document. With some documents, when attempting to save, we are getting this exception:

{"Key does not exist.\r\n"}
    Data: {System.Collections.ListDictionaryInternal}
    HResult: -2146893811
    HelpLink: null
    InnerException: null
    Message: "Key does not exist.\r\n"
    Source: "System.Security"
    StackTrace: "   at System.Security.Cryptography.Pkcs.SignedCms.ComputeSignature(CmsSigner signer, Boolean silent)\r\n   at Syncfusion.Pdf.Security.PdfSignatureDictionary.SignCertificate(Byte[] message, X509Certificate2 cert, Boolean detached)\r\n   at Syncfusion.Pdf.Security.PdfSignatureDictionary.GetStoreCertificate()\r\n   at Syncfusion.Pdf.Security.PdfSignatureDictionary.DocumentSaved(Object sender, DocumentSavedEventArgs e)\r\n   at Syncfusion.Pdf.PdfDocumentBase.OnDocumentSaved(DocumentSavedEventArgs args)\r\n   at Syncfusion.Pdf.Parsing.PdfLoadedDocument.Save(Stream stream)\r\n  "
    TargetSite: {Void ComputeSignature(System.Security.Cryptography.Pkcs.CmsSigner, Boolean)}

Can you explain what this is and how to avoid it?



Charles Southey
Replied On February 8, 2019 12:27 PM UTC

UPDATE: I have established that the cause is an invalid signature in the document, and have added a workaround to remove all signature fields as follows:

                                        var loadedSignatures = nextPDF?.Form?.Fields?.OfType<PdfLoadedSignatureField>().ToList() ?? new List<PdfLoadedSignatureField>();
                                        foreach (var loadedSignatureField in loadedSignatures)
                                        {
                                            nextPDF.Form.Fields.Remove(loadedSignatureField);
                                        }

However that's quite draconian - it would be better if it failed more gracefully and let us save the document without having to remove the field. Adobe reader identifies the invalid signature but still allows the file to be read etc.

Surya Kumar [Syncfusion]
Replied On February 11, 2019 09:27 AM UTC

Hi Charles, 

Greetings from Syncfusion. 

We suspect that the issue which you have mentioned is specific to the document so could you please provide us the PDF in which this issue is reproduced. So that it will be helpful for us to analyze and provide you a solution. 


Regards, 
Surya Kumar 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon