Customizing the Signature Widget with PDFSign
Requirements: Secure PDF
Introduction
This article explains how to place and customize a visible signature widget with the PDFSign component. It is intended for scenarios where your PDF does not already contain a signature field and you want to place signature(s) at a specific location. For a complete list of widget-related members, see the SignatureWidget* properties in our documentation: PDFSign properties.
Creating a Signature Widget
When you need a visible signature, configure placement using SignatureWidgetPages to target one or more pages (for example, "1", "1,3", or "1-3") and use SignatureWidgetOffsetX and SignatureWidgetOffsetY to position the widget in page coordinates measured in points from the left and bottom edges respectively. Control the size with SignatureWidgetWidth and SignatureWidgetHeight, also in points. Keep in mind that PDF page coordinates start at the bottom-left corner.
.NET example: place a widget and sign
```csharp using nsoftware.SecurePDF;
var signer = new PDFSign(); signer.Overwrite = true; signer.InputFile = @"C:\docs\in.pdf"; signer.OutputFile = @"C:\docs\out.signed.pdf";
// Load signing cert (PFX with private key) signer.SigningCert = new Certificate(CertStoreTypes.cstAuto, @"C:\certs\signer.pfx", "pfxPassword", "*");
// Place a visible signature on page 1 at (72,72) with 200x50 points signer.SignatureWidgetPages = "1"; signer.SignatureWidgetOffsetX = "72"; signer.SignatureWidgetOffsetY = "72"; signer.SignatureWidgetWidth = "200"; signer.SignatureWidgetHeight = "50";
signer.Sign(); ```
Customizing the Signature Widget
Beyond placement, you can customize the appearance and metadata of the widget. SignatureAuthorName lets you display a signer label beside the signature; SignatureReason conveys the purpose of signing. There is also the option to set the TimestampServer property to an RFC 3161 TSP endpoint so a trusted timestamp is embedded at signing time. These properties combine with the SignatureWidget* properties to produce a visible signature field on the PDF.
csharp
// Add these before calling Sign() to customize the visible appearance
signer.SignatureAuthorName = "Jane Doe";
signer.SignatureReason = "Approval";
signer.SignatureHashAlgorithm = "sha256";
// signer.TimestampServer = "https://tsa.example.com/";
Troubleshooting
If no appearance is shown after signing, ensure you are not setting SignatureField while also using widget properties. Also, verify that the target pages exist and the widget width and height are greater than zero. If the widget appears in an unexpected location, remember that coordinates are in points and the origin is the bottom-left corner. For encrypted PDFs, remember to set the Password (or DecryptionCert) before calling Sign.
For comprehensive reference details about the widget members and other signature options, see the PDFSign properties.
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.