How to add invisible signature to existing PDF

1 Answer 193 Views
PdfProcessing
Kamil Zmeskal
Top achievements
Rank 1
Kamil Zmeskal asked on 12 Jan 2023, 12:47 PM | edited on 12 Jan 2023, 01:05 PM

Hi ,
I cannot figure out how to add an invisible signature to an existing PDF.

My test code:


var pdfIn = "C:\\Prg\\Test\\TestTelerikPDF\\pdf\\demo.pdf";
var pdfSigned = $"{pdfIn}.sign.pdf";
var pfx = "C:\\Prg\\Test\\TestTelerikPDF\\pdf\\Cert.pfx";

using (var input = new FileStream(pdfIn, FileMode.Open, FileAccess.Read))
{
    var document = new PdfFormatProvider().Import(input);

    var certificate = new X509Certificate2(pfx, "passs");
    var signatureField = new SignatureField("Blabla");
    signatureField.Signature = new Signature(certificate);

    document.AcroForm.FormFields.Add(signatureField);

    var settings = new PdfExportSettings();
    settings.ComplianceLevel = PdfComplianceLevel.PdfA3B;

    var formatProvider = new PdfFormatProvider();
    formatProvider.ExportSettings = settings;

    using (var ms = new FileStream(pdfSigned, FileMode.Create))
        formatProvider.Export(document, ms);
}

This code create an output PDF but the signature is missing :-(

Can you help me please?

Best

Kamil 

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 17 Jan 2023, 11:16 AM

Hello Kamil,

By default, a document with an invisible signature must have its signature flags set. With this functionality, you can specify that there is a signature, even if the signature itself does not have a visual representation. You can read more about it in the New Features in the Telerik PdfProcessing Library in R2 2022 blog or in the Signature Flags section in the documentation.

If you are interested in a visual representation of the signature and a full, detailed example, you might find the Signing a document with a digital signature topic helpful.

If you happen to have any further questions, feel free to contact us.

Regards, Yoan Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
PdfProcessing
Asked by
Kamil Zmeskal
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or