For some time now we can sign PDFs with DynaPDFMBS class automatically in code. Recently we added a new feature to sign with Windows certificate store.
You can show the signature with adding a custom signature appearance. You define in your code how the PDF draws the signature on the page and includes the validation icon. That validation icon is a special feature of the PDF reader where they draw a checkmark to let you know the signature is valid. Like this screenshot:
We draw in the box there to show it’s signed, write the name there and then tell the PDF viewer to place the icon left to the text. If the PDF viewer doesn’t know or doesn’t check, this should display a question mark.
To do this, you do three steps:
- You call CreateSigField method to create a signature field on the PDF and specify the coordinates. You choose where to put it on the page and yes, you can render various areas and look for white space.
- To place the validation icon, please use our new PlaceSigFieldValidateIcon function. This receives relative coordinates within the signature field rectangle.
- Then use CreateSigFieldAP to create a custom signature field appearance stream and draw some text into it. You draw what you like within the given rectangle of your signature and the icon is later placed on top over the custom drawing. Please call EndTemplate when done with the drawing.
Now you save the PDF and use our CloseAndSignFile function to pass the file path to the private key file and let the plugin close the file with valid signature.
On Windows you can use CloseAndSignPDFFileWithDialog to use the Windows certificate store to pick the key to use for signing.