Multiple visible signatures (different positions)

Hi,
I am currently evaluating GemBox for use in our new product and we have a very specific use case.

Our clients have 100+ page long pdf files where they require visible signatures (eIDAS compliant) to appear on each page on different positions. We would like to help them by letting them automate this without having them to type-in pin for each page.

So my idea is to add visible signature locations through our custom feature and then sign them all using one pin-type. I’ve found out that there are software that can do this, so my question is if this is possible using GemBox.

At this point I can easily add as many visual signatures as I like through GemBox, but for the price of calling manually Sign() which would then of course trigger the pin dialogue.

Is it something I can do using this library?
Thanks
Jan

Hi Jan,

This is possible in PDF, but it seems that PDF specification disallows this (see https://stackoverflow.com/questions/49446542/placing-signature-in-multiple-location-on-same-page-while-signing-a-pdf/49447648#49447648 ).

Anyway, please use this latest NuGet package:

Install-Package GemBox.Pdf -Version 17.0.1553-hotfix

And try using this code (it is an extension of the Digitally sign a PDF file with a visible signature:

using (var document = PdfDocument.Load("Lines.pdf"))
{
    // Add a visible signature field to the first page of the PDF document.
    var signatureField = document.Form.Fields.AddSignature(document.Pages[0], 300, 500, 250, 100);

    // Retrieve the signature's appearance settings to customize it.
    var signatureAppearance = signatureField.Appearance;

    // Signature appearance will consist of a text above an image.
    signatureAppearance.TextPlacement = PdfTextPlacement.TextAboveIcon;
    // Text should occupy 40% of the annotation rectangle height. The rest will be occupied by the image.
    signatureAppearance.TextExtent = 0.4;
    // Text should be right aligned.
    signatureAppearance.TextAlignment = PdfTextAlignment.Right;
    // Set font. A zero value for font size means that the text is auto-sized to fit the annotation rectangle.
    signatureAppearance.Font = new PdfFont("Times New Roman", 0);
    // Show a 'Reason' label and value.
    signatureAppearance.Reason = "Legal agreement between the seller and the buyer about the purchase";
    // Show a 'Location' label and value.
    signatureAppearance.Location = "New York, USA";
    // Do not show a 'Date' label nor value.
    signatureAppearance.DateFormat = string.Empty;
    // Set the signature image.
    signatureAppearance.Icon = PdfImage.Load("GemBoxSignature.png");
    // The signature image should be scaled only if it is too big to fit.
    signatureAppearance.IconScaleCondition = PdfScaleCondition.ContentTooBig;
    // The signature image should dock to the bottom (y = 0) right (x = 1) corner.
    signatureAppearance.IconAlignment = new PdfPoint(1, 0);

    // Get a digital ID from PKCS#12/PFX file.
    var digitalId = new PdfDigitalId("GemBoxRSA1024.pfx", "GemBoxPassword");

    // Create a PDF signer that will create the digital signature.
    var signer = new PdfSigner(digitalId);

    // Adobe Acrobat Reader currently doesn't download the certificate chain
    // so we will also embed a certificate of intermediate Certificate Authority in the signature.
    // (see https://community.adobe.com/t5/acrobat/signature-validation-using-aia-extension-not-enabled-by-default/td-p/10729647)
    signer.ValidationInfo = new PdfSignatureValidationInfo(new PdfCertificate[] { new PdfCertificate(Path.Combine(desktop, "GemBoxRSA.crt")) }, null, null);

    // Initiate signing of a PDF file with the specified signer.
    signatureField.Sign(signer);

    // ----- EXTRA SIGNATURE WIDGETS START -----

    // Refresh and get the signature appearance form because we will use the same appearance form for all signature widgets on other pages.
    signatureAppearance.Refresh();
    var signatureAppearanceForm = signatureAppearance.Get();

    for (int i = 1; i < document.Pages.Count; ++i)
    {
        // Add a new signature field to the page.
        var nextSignatureField = document.Form.Fields.AddSignature(document.Pages[i], 300, 500, 250, 100);

        // Set the appearance form of the new signature to the one from the first page.
        nextSignatureField.Appearance.Set(signatureAppearanceForm);

        // Make the signature field name the same as the signature field on the first page.
        // This is the most important step.
        // This will basically merge signature fields into a single signature field that will have multiple widget annotations (one widget annotation on each page).
        nextSignatureField.Name = signatureField.Name;
    }

    // ----- EXTRA SIGNATURE WIDGETS END -----

    // Finish signing of a PDF file.
    document.Save("Visible Digital Signature.pdf");
}

I hope this helps.

Regards,
Mario

Thank you so much, Mario! It works absolutely stellar.

Jan