|
| 1 | +--- |
| 2 | +name: Facades - Sign Documents |
| 3 | +description: C# examples for Facades - Sign Documents using Aspose.PDF for .NET |
| 4 | +language: csharp |
| 5 | +framework: net10.0 |
| 6 | +parent: ../agents.md |
| 7 | +--- |
| 8 | + |
| 9 | +# AGENTS - Facades - Sign Documents |
| 10 | + |
| 11 | +## Persona |
| 12 | + |
| 13 | +You are a C# developer specializing in PDF processing using Aspose.PDF for .NET, |
| 14 | +working within the **Facades - Sign Documents** category. |
| 15 | +This folder contains standalone C# examples for Facades - Sign Documents operations. |
| 16 | +See the root [agents.md](../agents.md) for repository-wide conventions and boundaries. |
| 17 | + |
| 18 | +## Scope |
| 19 | +- This folder contains examples for **Facades - Sign Documents**. |
| 20 | +- Files are standalone `.cs` examples stored directly in this folder. |
| 21 | + |
| 22 | +## Required Namespaces |
| 23 | + |
| 24 | +- `using Aspose.Pdf.Facades;` (30/32 files) ← category-specific |
| 25 | +- `using Aspose.Pdf;` (15/32 files) |
| 26 | +- `using Aspose.Pdf.Forms;` (13/32 files) |
| 27 | +- `using Aspose.Pdf.Text;` (1/32 files) |
| 28 | +- `using System;` (32/32 files) |
| 29 | +- `using System.IO;` (29/32 files) |
| 30 | +- `using System.Collections.Generic;` (8/32 files) |
| 31 | +- `using System.Drawing;` (8/32 files) |
| 32 | +- `using System.Globalization;` (2/32 files) |
| 33 | +- `using System.Security.Cryptography.X509Certificates;` (2/32 files) |
| 34 | +- `using System.Linq;` (1/32 files) |
| 35 | +- `using System.Text;` (1/32 files) |
| 36 | +- `using System.Text.Json;` (1/32 files) |
| 37 | + |
| 38 | +## Common Code Pattern |
| 39 | + |
| 40 | +Most files follow this pattern: |
| 41 | + |
| 42 | +```csharp |
| 43 | +using (Document doc = new Document("input.pdf")) |
| 44 | +{ |
| 45 | + // ... operations ... |
| 46 | + doc.Save("output.pdf"); |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +## Files in this folder |
| 51 | + |
| 52 | +| File | Title | Key APIs | Description | |
| 53 | +|------|-------|----------|-------------| |
| 54 | +| [add-digital-signature](./add-digital-signature.cs) | Add Digital Signature with Reason and Location | `PdfFileSignature`, `BindPdf`, `SetCertificate` | Demonstrates how to add a visible digital signature to a PDF and set the signature reason and loc... | |
| 55 | +| [add-second-digital-signature-page-three](./add-second-digital-signature-page-three.cs) | Add a second digital signature on page three of a PDF | `PdfFileSignature`, `BindPdf`, `SetCertificate` | Demonstrates adding two digital signatures to a PDF, with the second placed on page three using a... | |
| 56 | +| [add-signature-field](./add-signature-field.cs) | Add Signature Field and Sign PDF | `Document`, `Form`, `SignatureField` | Demonstrates adding a signature field to a specific page and then signing the PDF using a certifi... | |
| 57 | +| [custom-signature-appearance](./custom-signature-appearance.cs) | Create Custom Signature Appearance without Default Caption | `Document`, `Page`, `Rectangle` | Demonstrates how to create a PDF signature field with a custom appearance that hides the default ... | |
| 58 | +| [digitally-sign-pdf-page-one](./digitally-sign-pdf-page-one.cs) | Digitally Sign PDF on First Page | `PdfFileSignature`, `BindPdf`, `SetCertificate` | Demonstrates how to bind a PDF with PdfFileSignature, set a certificate, and add a digital signat... | |
| 59 | +| [extract-certificate-details](./extract-certificate-details.cs) | Extract Certificate Issuer and Expiration from Signed PDF | `PdfFileSignature`, `GetSignatureNames`, `TryExtractCertificate` | Demonstrates how to read a signed PDF, retrieve each signature's X.509 certificate, and display i... | |
| 60 | +| [extract-certificate-serial-number](./extract-certificate-serial-number.cs) | Extract Signing Certificate Serial Number from PDF | `PdfFileSignature`, `BindPdf`, `GetSignatureNames` | Loads a signed PDF, extracts the signing certificate from the first signature field, and logs its... | |
| 61 | +| [extract-signature-image](./extract-signature-image.cs) | Extract Signature Field Image to PNG | `Document`, `Form`, `ExtractImage` | Demonstrates extracting the image from a signature form field named 'WitnessSignature' and saving... | |
| 62 | +| [extract-signature-images-html](./extract-signature-images-html.cs) | Extract Signature Images and Generate HTML Report | `Document`, `PdfFileSignature`, `SignatureName` | Extracts signature images from a signed PDF and creates an HTML file that displays each signature... | |
| 63 | +| [extract-signing-certificate](./extract-signing-certificate.cs) | Extract Signing Certificate from PDF Signature Field | `PdfFileSignature`, `ExtractCertificate`, `SignatureName` | Demonstrates how to extract the X.509 certificate from a PDF signature field named 'LegalSignatur... | |
| 64 | +| [list-pdf-signature-names](./list-pdf-signature-names.cs) | List Signature Names in PDF | `PdfFileSignature`, `BindPdf`, `GetSignNames` | Demonstrates how to retrieve and display all digital signature names from a PDF using Aspose.Pdf. | |
| 65 | +| [list-signature-reason-location](./list-signature-reason-location.cs) | List Signature Reasons and Locations in PDF | `PdfFileSignature`, `BindPdf`, `GetSignatureNames` | Demonstrates how to enumerate digital signatures in a PDF and output each signature's reason and ... | |
| 66 | +| [locale-specific-signature](./locale-specific-signature.cs) | Locale-Specific Signature Text in PDF | `PdfFileSignature`, `BindPdf`, `SetCertificate` | Adds a visible digital signature to a PDF with signature text adapted to German, Spanish, or Japa... | |
| 67 | +| [pdf-signature-report](./pdf-signature-report.cs) | Generate PDF Signature Report | `PdfFileSignature`, `BindPdf`, `GetSignatureNames` | Creates a PDF summarizing each digital signature's name, signer, and verification result from an ... | |
| 68 | +| [remove-all-signatures](./remove-all-signatures.cs) | Remove All Signatures from PDF | `PdfFileSignature`, `BindPdf`, `RemoveSignatures` | Demonstrates how to remove every digital signature from a PDF file using Aspose.Pdf's PdfFileSign... | |
| 69 | +| [remove-and-resign-pdf](./remove-and-resign-pdf.cs) | Remove Existing Signatures and Re‑sign PDF with New Certific... | `PdfFileSignature`, `BindPdf`, `RemoveSignatures` | Demonstrates how to remove all signatures from a PDF and then apply a new digital signature using... | |
| 70 | +| [remove-pdf-signature](./remove-pdf-signature.cs) | Remove Specific Signature from PDF | `PdfFileSignature`, `BindPdf`, `RemoveSignature` | Demonstrates how to remove a digital signature named 'ApprovalSignature' from a PDF using Aspose.... | |
| 71 | +| [remove-pdf-signatures](./remove-pdf-signatures.cs) | Remove All Signatures from PDFs in a Directory | `PdfFileSignature`, `BindPdf`, `RemoveSignatures` | Recursively scans a directory for PDF files, removes all digital signatures from each PDF, and sa... | |
| 72 | +| [remove-signature-with-error-handling](./remove-signature-with-error-handling.cs) | Remove Specific Signature with Error Handling | `PdfFileSignature`, `SignatureName`, `GetSignatureNames` | Shows how to safely remove a named digital signature from a PDF, checking for its existence and h... | |
| 73 | +| [set-french-language-signature](./set-french-language-signature.cs) | Set French Language for Digital Signature Caption | `PdfFileSignature`, `BindPdf`, `SetCertificate` | Demonstrates how to change the language of a digital signature caption to French by setting the S... | |
| 74 | +| [set-signature-background](./set-signature-background.cs) | Set Semi-Transparent Background for PDF Signature Appearance | `PdfFileSignature`, `SignatureCustomAppearance`, `Color` | Demonstrates how to configure a PDF signature's custom appearance with a semi‑transparent backgro... | |
| 75 | +| [sign-pdf-empty-signature-fields](./sign-pdf-empty-signature-fields.cs) | Sign PDF with Empty Reason, Contact, and Location | `PdfFileSignature`, `BindPdf`, `SetCertificate` | Demonstrates how to sign a PDF using Aspose.Pdf while suppressing the reason, contact, and locati... | |
| 76 | +| [sign-pdf-hidden-appearance](./sign-pdf-hidden-appearance.cs) | Sign PDF with Hidden Signature Appearance | `PdfFileSignature`, `PKCS7`, `BindPdf` | Demonstrates how to apply a cryptographically valid digital signature to a PDF while completely h... | |
| 77 | +| [sign-pdf-pfx](./sign-pdf-pfx.cs) | Sign PDF with PFX Certificate | `PdfFileSignature`, `BindPdf`, `SetCertificate` | Demonstrates how to digitally sign a PDF using a password‑protected PFX certificate. | |
| 78 | +| [sign-pdf-visible-last-page](./sign-pdf-visible-last-page.cs) | Sign PDF with Visible Signature on Last Page | `PdfFileSignature`, `Document`, `Page` | Demonstrates how to add a visible digital signature to the bottom‑right corner of the last page o... | |
| 79 | +| [sign-pdf-with-image](./sign-pdf-with-image.cs) | Sign PDF with Image Signature | `PdfFileSignature`, `Document`, `BindPdf` | Demonstrates how to apply an image signature to a PDF using Aspose.Pdf's PdfFileSignature facade. | |
| 80 | +| [signature-custom-appearance](./signature-custom-appearance.cs) | Configure SignatureCustomAppearance with Foreground Image an... | `PdfFileSignature`, `SignatureCustomAppearance`, `Document` | Demonstrates how to set a background color and draw the signature image as a foreground image usi... | |
| 81 | +| [validate-pdf-signature](./validate-pdf-signature.cs) | Validate PDF Signature Integrity | `PdfFileSignature`, `VerifySignature` | Demonstrates how to verify the cryptographic integrity of a PDF signature field named 'ManagerSig... | |
| 82 | +| [verify-multiple-signatures](./verify-multiple-signatures.cs) | Verify Multiple Signatures in PDF | `PdfFileSignature`, `BindPdf`, `GetSignNames` | Demonstrates how to list all signature names in a PDF and verify each signature using PdfFileSign... | |
| 83 | +| [verify-pdf-no-signatures](./verify-pdf-no-signatures.cs) | Verify PDF Without Signatures Returns False | `PdfFileSignature`, `BindPdf`, `ContainsSignature` | Demonstrates checking a PDF that has no digital signatures using PdfFileSignature.VerifySigned, w... | |
| 84 | +| ... | | | *and 2 more files* | |
| 85 | + |
| 86 | +## Category Statistics |
| 87 | +- Total examples: 32 |
| 88 | + |
| 89 | +## Category-Specific Tips |
| 90 | + |
| 91 | +### Key API Surface |
| 92 | +- `Aspose.Pdf.Document` |
| 93 | +- `Aspose.Pdf.Facades.Algorithm` |
| 94 | +- `Aspose.Pdf.Facades.DocMDPAccessPermissions` |
| 95 | +- `Aspose.Pdf.Facades.DocMDPSignature` |
| 96 | +- `Aspose.Pdf.Facades.DocumentPrivilege` |
| 97 | +- `Aspose.Pdf.Facades.KeySize` |
| 98 | +- `Aspose.Pdf.Facades.PKCS7` |
| 99 | +- `Aspose.Pdf.Facades.PdfFileInfo` |
| 100 | +- `Aspose.Pdf.Facades.PdfFileSecurity` |
| 101 | +- `Aspose.Pdf.Facades.PdfFileSecurity.BindPdf` |
| 102 | +- `Aspose.Pdf.Facades.PdfFileSecurity.EncryptFile` |
| 103 | +- `Aspose.Pdf.Facades.PdfFileSecurity.Save` |
| 104 | +- `Aspose.Pdf.Facades.PdfFileSignature` |
| 105 | +- `Aspose.Pdf.Facades.PdfFileSignature.BindPdf` |
| 106 | +- `Aspose.Pdf.Facades.PdfFileSignature.Certify` |
| 107 | + |
| 108 | +### Rules |
| 109 | +- Create a PdfFileInfo for {input_pdf} and read its IsEncrypted property to obtain a {bool} indicating whether the PDF is encrypted (password‑protected). |
| 110 | +- Use PdfFileInfo instead of loading a full Document when only document metadata such as encryption status is needed. |
| 111 | +- Instantiate PdfFileSecurity, call BindPdf({input_pdf}) to load the encrypted PDF, then invoke DecryptFile({string_literal}) with the owner password to decrypt it. |
| 112 | +- After decryption, call Save({output_pdf}) on the PdfFileSecurity instance to write the unprotected PDF to disk. |
| 113 | +- Instantiate {class} (PdfFileSecurity), call BindPdf({input_pdf}) to load the document, then invoke ChangePassword({owner_password}, {new_user_password}, {new_owner_password}) to set new passwords, and finally Save({output_pdf}) to write the protected file. |
| 114 | + |
| 115 | +### Warnings |
| 116 | +- DecryptFile requires the owner password; decryption with only a user password is not covered by this example. |
| 117 | +- The example assumes the PDF is protected with an owner password; if the PDF has no password, an empty string may be required for the current owner password. |
| 118 | +- PdfFileSecurity belongs to the Aspose.Pdf.Facades namespace, which may be deprecated in future releases; consider using the newer Aspose.Pdf.Security namespace if available. |
| 119 | +- A valid PKCS#7 certificate file and correct password are required; otherwise signing will fail. |
| 120 | +- Custom appearance may not be rendered identically across all PDF viewers. |
| 121 | + |
| 122 | +## General Tips |
| 123 | +- See parent [agents.md](../agents.md) for: |
| 124 | + - **Boundaries** — Always / Ask First / Never rules for all examples |
| 125 | + - **Common Mistakes** — verified anti-patterns that cause build failures |
| 126 | + - **Domain Knowledge** — cross-cutting API-specific gotchas |
| 127 | + - **Testing Guide** — build and run verification steps |
| 128 | +- Review code examples in this folder for Facades - Sign Documents patterns |
| 129 | + |
| 130 | +<!-- AUTOGENERATED:START --> |
| 131 | +Updated: 2026-04-01 | Run: `20260401_103902_81d716` |
| 132 | +<!-- AUTOGENERATED:END --> |
0 commit comments