Adding visible digital signatures to a PDF document
Use visible digital signatures to combine visual signoff with cryptographic integrity.
Common use cases include:
- Contract signing workflows
- Document approval systems
- Authenticated signoff pipelines
- Branded signature appearances
Unlike invisible signatures, visible signatures render a signature area on the page using text or images.
Download sampleHow Nutrient helps
Nutrient Python SDK handles signature field operations, appearance rendering, and cryptographic signing.
The SDK handles:
- Signature field dictionaries and appearance streams
- PKCS#12 certificate loading and key extraction
- Appearance customization and font rendering
- Byte range calculations and signing internals
Complete implementation
This example adds a visible signature field and signs it with different appearance options:
from nutrient_sdk import Document, PdfEditor, Signature, Colorfrom nutrient_sdk import DigitalSignatureOptions, SignatureAppearance, TimestampConfigurationfrom nutrient_sdk import SignatureHashAlgorithmCreating a signature field
Create a signature field at the target location before signing.
In this sample:
- The document opens in a context manager(opens in a new tab).
- The field name is
ApprovalSignature. - The position is
(100, 700). - The size is
200 × 50.
The field acts as the visible placeholder for the signed appearance:
with Document.open("input.pdf") as document: editor = PdfEditor.edit(document) page = editor.page_collection.first
signature_field = editor.form_field_collection.add_signature_field( name="ApprovalSignature", page=page, x=100.0, y=700.0, width=200.0, height=50.0 )
editor.save_as("output_document_with_field.pdf") editor.close()Signing with auto-generated appearance
Sign the field with metadata-driven text.
In this sample:
DigitalSignatureOptionssets certificate and signer metadata.Document.open("output_document_with_field.pdf")opens the PDF before signing.use_auto_generated_text = Trueuses signer metadata in the appearance.show_validation_mark = Trueadds a validation indicator.sign_field(document, output_path, field_name, options, appearance)signs"ApprovalSignature".
with Signature() as signer, Document.open("output_document_with_field.pdf") as document: options = DigitalSignatureOptions() options.certificate_path = "certificate.pfx" options.certificate_password = "Nutrient answers all your document needs" options.signer_name = "John Doe" options.reason = "Final Approval" options.location = "New York"
appearance = SignatureAppearance() appearance.use_auto_generated_text = True appearance.show_validation_mark = True
signer.sign_field( document, "output_signed_visible.pdf", "ApprovalSignature", options, appearance )Signing with a custom image
Use an image-based appearance for handwritten signatures or logos.
In this sample:
Document.open("output_document_with_field.pdf")opens the PDF before signing.image_pathpoints to the signature image file.- The image renders inside field bounds.
show_validation_mark = Truekeeps the validation indicator visible.sign_field(document, output_path, field_name, options, appearance)applies the digital signature.
with Signature() as signer, Document.open("output_document_with_field.pdf") as document: options = DigitalSignatureOptions() options.certificate_path = "certificate.pfx" options.certificate_password = "Nutrient answers all your document needs" options.signer_name = "Jane Smith" options.reason = "Review Complete"
appearance = SignatureAppearance() appearance.image_path = "input_signature.jpg" appearance.show_validation_mark = True
signer.sign_field( document, "output_signed_with_image.pdf", "ApprovalSignature", options, appearance )Signing with custom text
Use custom text when you need workflow-specific signature content.
In this sample:
Document.open("output_document_with_field.pdf")opens the PDF before signing.use_auto_generated_text = Falsedisables metadata-generated text.textdefines the visible signature content.\ncreates multiline output.sign_field(document, output_path, field_name, options, appearance)applies the digital signature.
with Signature() as signer, Document.open("output_document_with_field.pdf") as document: options = DigitalSignatureOptions() options.certificate_path = "certificate.pfx" options.certificate_password = "Nutrient answers all your document needs" options.signer_name = "Manager"
appearance = SignatureAppearance() appearance.use_auto_generated_text = False appearance.text = "Approved by Management\nDate: 2024-01-15"
signer.sign_field( document, "output_signed_custom_text.pdf", "ApprovalSignature", options, appearance )Customizing text appearance
Customize typography to match document or brand requirements.
In this sample:
Document.open("output_document_with_field.pdf")opens the PDF before signing.font_namesets the typeface.font_sizesets text size.text_colorsets ARGB color values.sign_field(document, output_path, field_name, options, appearance)applies the digital signature.
with Signature() as signer, Document.open("output_document_with_field.pdf") as document: options = DigitalSignatureOptions() options.certificate_path = "certificate.pfx" options.certificate_password = "Nutrient answers all your document needs" options.signer_name = "Executive"
appearance = SignatureAppearance() appearance.use_auto_generated_text = False appearance.text = "Approved by Executive Board" appearance.font_name = "Times New Roman" appearance.font_size = 14.0 appearance.text_color = Color.from_argb(255, 0, 0, 128) # Navy blue
signer.sign_field( document, "output_signed_styled_text.pdf", "ApprovalSignature", options, appearance )Conclusion
Use this workflow to add visible digital signatures:
- Open the document using a context manager(opens in a new tab) for automatic resource cleanup.
- Create an editor and access the page collection.
- Add a signature field at specified coordinates with defined dimensions (e.g. 100, 700, 200×50 points).
- The signature field creates a rectangular placeholder for the signature appearance.
- Sign the field using
Signaturewith certificate credentials (PKCS#12 format). - Configure signing metadata, including signer name, reason, and location.
- Create the signature appearance with auto-generated text (
use_auto_generated_text = True) to display metadata. - Add validation marks (
show_validation_mark = True) to indicate signature validity. - Use custom images via the
image_pathproperty for handwritten signatures or company logos. - Use custom text with
use_auto_generated_text = Falseand multiline formatting for workflow-specific approvals. - Customize typography with
font_name,font_size, andtext_colorproperties using ARGB values. - Save the signed document with visible signature appearance and cryptographic integrity.
For related signing workflows, refer to the Python SDK guides.