Display signature information when using custom signing api

Hi there,

I am making a small proof of concept to determine if pdftron can achieve the following scenario for the application I am working on, before potentially buying a licence:

  • Open a pdf document with existing unsigned signature fields,
  • Calculate the required digest to send to a third-party api which itself returns the signature,
  • Put the signature in the pdf and save.

So far the signing part works fine, but I can’t get it to be displayed on the pdf. I can only see the signature in the ‘Signatures’ tab in Acrobat Reader for example.
I am expecting to see the contact info, reason, location, signing time, etc. where the signing widget is, but it stays blank whatever I tried.

This is basically what I do at the moment:

// Open the pdf, retrieve the signature, create a dictionnary and add some values
using PDFDoc doc = new PDFDoc(inputFile);
var field = doc.GetField(“signature_1”);
var sig = new DigitalSignatureField(field);
sig.CreateSigDictForCustomSigning(“Adobe.PPKLite”, DigitalSignatureField.SubFilterType.e_adbe_pkcs7_detached, 31000);
sig.SetContactInfo(“contact info”);
sig.SetReason(“reason”);
sig.SetLocation(“location”);
doc.Save(outputFile, SaveOptions.e_incremental);

// Calculate the digest
byte[] pdf_digest = sig.CalculateDigest(DigestAlgorithm.Type.e_sha512);

// […] call the api which returns the signature and save
byte[] signatureBytes = // omitted
doc.SaveCustomSignature(signatureBytes, sig, outputFile);

Do I miss a step regarding the signature appearance?

Best Regards,
Xavier

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Appearances are optional for at least the Author signature, though the approval ones it is expected they are added.

There is a new API to allow you set the appearance from an image in the Annots.SignatureWidget class.

SignatureWidhet.CreateSignatureAppearance(Image)
https://www.pdftron.com/api/PDFTronSDK/dotnet/pdftron.PDF.Annots.SignatureWidget.html#pdftron_PDF_Annots_SignatureWidget_CreateSignatureAppearance_pdftron_PDF_Image_

Example usage here.

As for the image itself there are a variety of ways to create one, for instance creating a PDF page and using PDFDraw to convert to an image.

Or if you want to add one manually you see this post.