This is a migrated thread and some comments may be shown as answers.

Adobe Acrobat error after signing PDF

1 Answer 962 Views
PdfProcessing
This is a migrated thread and some comments may be shown as answers.
MichaelC
Top achievements
Rank 1
MichaelC asked on 18 Feb 2020, 10:49 PM

We are already using Telerik UI for WPF R1 2018 SP2 in C# .Net, and now we would like to use the PdfProcessing libraries to digitally sign a PDF document.

 

Using the code from here, https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/features/digital-signature I crafted a method to sign a PDF document. However, the resulting signed PDF gets an error when opened in Adobe Acrobat: hovering over the signature field gets a tooltip with "error during validation", and selecting the signature field opens a dialog box that says "Error during signature verification. Adobe Acrobat error. Expected a dict object." If I right-click the signature field and select View Signed Version in the popup menu, and select View Report in that view, I get a dialog box that says "Unrecognized PDF content: The document contains PDF content or custom content not supported by the current version of Adobe Acrobat Reader." with a report code of 4000.

 

This is the code I'm using; is there something I'm missing? Like I mentioned, I'm using the code from the Telerik Docs, with the exceptions that the input and output are byte arrays, and the size and position come from passed in metadata realized through the ParseSignaturePosition() method.

 

private byte[] MySignPDF(byte[] pdfData, IDocumentStore documentStoreItem, X509Certificate2 certificate)
{
    var sourcePdfDocument = new PdfFormatProvider().Import(pdfData);
    (int signaturePositionTop, int signaturePositionLeft, int signatureFieldWidth, int signatureFieldHeight, int signatureFieldPage) =
        ParseSignaturePosition(documentStoreItem, sourcePdfDocument);

    var pdfForm = new Form();
    pdfForm.FormSource = new FormSource();
    pdfForm.FormSource.Size = new Size(signatureFieldWidth, signatureFieldHeight);

    var editor = new FixedContentEditor(pdfForm.FormSource);
    pdfForm.Position.Translate(signaturePositionLeft, signaturePositionTop);
    editor.DrawText($"{certificate.GetNameInfo(X509NameType.SimpleName, false)} {DateTime.Now.ToString("yyyy.MM.dd HH:mm")}");

    var pdfSignature = new SignatureField("SignatureField");
    pdfSignature.Signature = new Signature(certificate);

    var signatureWidget = pdfSignature.Widgets.AddWidget();
    signatureWidget.Content.NormalContentSource = pdfForm.FormSource;
    signatureWidget.Rect = new Rect(
        new Point(signaturePositionLeft, signaturePositionTop),
        new Size(signatureFieldWidth, signatureFieldHeight));
    signatureWidget.RecalculateContent();

    var pdfPage = sourcePdfDocument.Pages[signatureFieldPage];
    pdfPage.Annotations.Add(signatureWidget);

    var pageEditor = new FixedContentEditor(pdfPage);
    pageEditor.Position.Translate(signaturePositionLeft, signaturePositionTop);
    pageEditor.DrawForm(pdfForm.FormSource);
    sourcePdfDocument.AcroForm.FormFields.Add(pdfSignature);
    signatureWidget.RecalculateContent();

    return new PdfFormatProvider().Export(sourcePdfDocument);
}

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 19 Feb 2020, 12:55 PM

Hello Michael,

This is a known issue that is already logged on our feedback portal. You can track its progress, subscribe to status changes and add your comment to it here:https://feedback.telerik.com/document-processing/1410844-pdfprocessing-signing-document-with-signature-field-produces-document-which-leads-to-error-in-adobe-acrobat.

Unfortunately, I cannot suggest a workaround for the issue.

Thank you for your understanding.

Regards,
Dimitar
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
PdfProcessing
Asked by
MichaelC
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or