Class PdfSignatureExtensions
Extension methods for PdfSignature to sign PDF files directly without loading into memory. Provides convenient file-based signing operations for batch processing.
Example - Sign PDF file:
var signature = new PdfSignature("certificate.pfx", "password");
signature.SignPdfFile("document.pdf", removeOldSignatures: true);
Inheritance
Namespace: IronPdf.Signing
Assembly: IronPdf.dll
Syntax
public static class PdfSignatureExtensions : Object
Remarks
Related Resources:
Methods
SignPdfFile(PdfSignature, String, Boolean, String, String)
Digitally signs an existing PDF file using the specified certificate. The file is loaded, signed, and saved back to the same path.
Example:
var signature = new PdfSignature("certificate.pfx", "password");
// Sign single file:
signature.SignPdfFile("contract.pdf");
// Sign encrypted PDF with old signatures removed:
signature.SignPdfFile("encrypted.pdf",
removeOldSignatures: true,
userPassword: "user123",
ownerPassword: "owner456");
// Batch sign multiple files:
foreach (var file in Directory.GetFiles("contracts", "*.pdf"))
{
signature.SignPdfFile(file, removeOldSignatures: true);
}
Declaration
public static bool SignPdfFile(this PdfSignature signature, string pdfFilePath, bool removeOldSignatures = false, string userPassword = null, string ownerPassword = null)
Parameters
| Type | Name | Description |
|---|---|---|
| PdfSignature | signature | The PdfSignature certificate to use for signing. |
| System.String | pdfFilePath | Full or relative path to the PDF file to sign. |
| System.Boolean | removeOldSignatures | If |
| System.String | userPassword | User password if the PDF is encrypted for viewing (default: null). |
| System.String | ownerPassword | Owner password if the PDF has restricted permissions (default: null). |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|