Retrieving Signature Field Icon Returns Null in Gembox.Pdf


I am working on an implementation involving the insertion of a signature image into a PDF document using the Gembox.Pdf library. While I’m able to insert the image successfully, I’m encountering an issue when I attempt to retrieve the image after saving and reloading the PDF.

Here’s the code snippet I use to insert the image:

var appearance = signField.Appearance; 
appearance.TextPlacement = PdfTextPlacement.IconOnly;
appearance.Icon = PdfImage.Load(new MemoryStream(Image));
appearance.IconScaleCondition = PdfScaleCondition.Always; 
appearance.IconScaleProportional = true; 
appearance.IconAlignment = new PdfPoint(0.5, 0.5);

The image is inserted as expected, and the resulting PDF visually shows the signature image.

However, after saving the PDF and reloading it using Gembox.Pdf, I find that the appearance.Icon property is null. I expected this property to contain the inserted PdfImage object.

Is this behavior a known issue, or am I missing something in the process? Could you guide me on how to retrieve the image of the signature field?

Any assistance you can provide would be greatly appreciated. Thank you!

Best regards,

Hi Jindřich,

Most of the properties of the PdfSignatureAppearance class are not preserved in the signed PDF file. Their only purpose is to provide customization of the signature appearance generation.

The signature icon image ends up in the signature appearance layer in the signed PDF file and you can retrieve it like this:

var signatureIconContent = signatureField.Appearance.SignatureLayer.Content.Elements.All().OfType<PdfImageContent>().Single();
signatureIconContent.Save(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Signature.png"));

var signatureIcon = signatureIconContent.Image;


Hi Stipo,

Thank you for the solution. I have tried it out and it works perfectly. I appreciate your prompt and helpful response.

Best regards,