DEV Community

IronSoftware
IronSoftware

Posted on

How to Put Your Signature in a PDF in C#

Our contracts needed signatures. Email back-and-forth with scanned copies was tedious. Clients printed, signed, scanned, and emailed. Days wasted.

PDF signatures eliminated paper entirely. Here's how to add both digital certificates and handwritten signature images.

What Are the Types of PDF Signatures?

Three main types:

using IronPdf;
// Install via NuGet: Install-Package IronPdf

var pdf = PdfDocument.FromFile("contract.pdf");

// 1. Digital/Cryptographic signature (invisible, proves authenticity)
pdf.SignWithFile("certificate.pfx", "password");

// 2. Visual signature image (handwritten signature stamp)
pdf.DrawBitmap(signatureImage, 400, 100, 0);

// 3. Interactive signature field (user signs later)
// Covered below

pdf.SaveAs("signed.pdf");
Enter fullscreen mode Exit fullscreen mode

Digital signatures prove authenticity. Visual signatures provide appearance. Interactive fields enable end-user signing.

How Do I Add a Digital Signature?

Use a certificate file (.pfx or .p12):

var pdf = PdfDocument.FromFile("agreement.pdf");

pdf.SignWithFile("mycert.pfx", "certPassword");

pdf.SaveAs("digitally-signed.pdf");
Enter fullscreen mode Exit fullscreen mode

The signature is cryptographic proof. Invisible but verifiable in Adobe Acrobat (shows blue ribbon icon).

Where Do I Get a Certificate?

Option 1: Purchase from Certificate Authority

  • DigiCert, GlobalSign, Sectigo
  • Costs $50-300/year
  • Publicly trusted

Option 2: Self-signed certificate

  • Free, for internal use only
  • Not trusted by external parties
# Generate self-signed (Windows PowerShell)
$cert = New-SelfSignedCertificate -Subject "CN=MyCompany" -Type CodeSigningCert
Export-PfxCertificate -Cert $cert -FilePath certificate.pfx -Password (ConvertTo-SecureString "password" -AsPlainText -Force)
Enter fullscreen mode Exit fullscreen mode

I use self-signed for internal documents, commercial certs for client-facing contracts.

Can I Add a Visible Signature Image?

Yes, stamp an image onto the PDF:

using System.Drawing;

var pdf = PdfDocument.FromFile("document.pdf");

using var signature = new Bitmap("john-signature.png");

// Position signature on page 0
pdf.DrawBitmap(signature, x: 400, y: 100, pageIndex: 0,
    width: 200, height: 80);

pdf.SaveAs("visually-signed.pdf");
Enter fullscreen mode Exit fullscreen mode

Common workflow: scan your handwritten signature once, reuse the image programmatically.

How Do I Combine Digital + Visual Signatures?

Apply both:

// First: Add visible signature image
using var signatureImage = new Bitmap("ceo-signature.png");
pdf.DrawBitmap(signatureImage, 400, 100, 0, 200, 80);

// Second: Apply cryptographic signature
pdf.SignWithFile("certificate.pfx", "password");

pdf.SaveAs("fully-signed.pdf");
Enter fullscreen mode Exit fullscreen mode

Best of both: visual appearance AND cryptographic proof.

Can I Add Signature Fields for Users?

Yes, create fillable signature fields:

using IronPdf.Forms;

var pdf = PdfDocument.FromFile("blank-contract.pdf");

var signatureField = new SignatureFormField
{
    Name = "client_signature",
    PageIndex = 0,
    X = 100,
    Y = 150,
    Width = 200,
    Height = 60
};

pdf.Form.Fields.Add(signatureField);

pdf.SaveAs("contract-with-sig-field.pdf");
Enter fullscreen mode Exit fullscreen mode

Users open in Adobe Acrobat/Reader and sign electronically.

How Do I Sign with X509Certificate2?

Use certificates from Windows Certificate Store:

using System.Security.Cryptography.X509Certificates;

var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);

var cert = store.Certificates
    .Find(X509FindType.FindBySubjectName, "MyCompany", false)[0];

pdf.SignWithCertificate(cert);

pdf.SaveAs("signed.pdf");
Enter fullscreen mode Exit fullscreen mode

Useful in enterprise environments with centralized certificate management.

Can I Add Metadata to Signatures?

Yes, include reason, location, contact info:

using IronPdf.Signing;

var signature = new PdfSignature("certificate.pfx", "password")
{
    SigningReason = "Contract approval",
    SigningLocation = "New York Office",
    SigningContactInfo = "legal@company.com"
};

pdf.Sign(signature);
Enter fullscreen mode Exit fullscreen mode

Metadata appears when verifying the signature in PDF readers.

How Do I Position Signatures Precisely?

Use PDF coordinate system (points from bottom-left):

// Bottom-right corner of standard letter page (612x792)
int x = 400;
int y = 50;

pdf.DrawBitmap(signatureImage, x, y, 0, 180, 60);
Enter fullscreen mode Exit fullscreen mode

Or measure in your PDF viewer to find exact coordinates.

Can I Add Multiple Signatures?

Yes, for multi-party agreements:

// CEO signature
pdf.DrawBitmap(ceoSig, 100, 150, 0);
pdf.SignWithFile("ceo-cert.pfx", "ceoPass");

// CFO signature (incremental signing)
pdf.DrawBitmap(cfoSig, 400, 150, 0);
pdf.SignWithFile("cfo-cert.pfx", "cfoPass");

pdf.SaveAs("multi-signed.pdf");
Enter fullscreen mode Exit fullscreen mode

Each signature is independent. Order matters for verification.

How Do I Verify Signatures Programmatically?

IronPDF focuses on signing, not verification. Use iTextSharp or Adobe PDF Library for verification:

// Verification typically done by PDF readers
// Adobe Acrobat shows signature panel with verification status
Enter fullscreen mode Exit fullscreen mode

Or call Adobe's PDF Library API if programmatic verification is needed.

What About Timestamp Authorities?

Add trusted timestamps for long-term validity:

var signature = new PdfSignature("certificate.pfx", "password")
{
    TimestampUrl = "http://timestamp.digicert.com"
};

pdf.Sign(signature);
Enter fullscreen mode Exit fullscreen mode

Timestamps prove when the signature was applied, even if the certificate expires later.

Can I Sign PDFs in Batch?

Yes, loop through files:

var files = Directory.GetFiles("contracts", "*.pdf");

foreach (var file in files)
{
    var pdf = PdfDocument.FromFile(file);

    pdf.SignWithFile("company-cert.pfx", "password");

    var outputPath = file.Replace("contracts", "signed");
    pdf.SaveAs(outputPath);
}
Enter fullscreen mode Exit fullscreen mode

Automate signing for hundreds of documents.

How Do I Handle Signature Permissions?

Control what's allowed after signing:

using IronPdf.Signing;

var signature = new PdfSignature("certificate.pfx", "password")
{
    Permissions = SignaturePermissions.NoChangesAllowed
};

pdf.Sign(signature);
Enter fullscreen mode Exit fullscreen mode

Options: NoChangesAllowed, FormFillingAllowed, AnnotationsAllowed

What's Best Practice for Security?

Certificate storage: Never hardcode passwords. Use Azure Key Vault or environment variables.
Private keys: Protect .pfx files with strong passwords, restricted file permissions.
Certificate expiry: Monitor expiration dates, renew proactively.
Audit trail: Log all signing operations.

// Use environment variable for password
var password = Environment.GetEnvironmentVariable("CERT_PASSWORD");

pdf.SignWithFile("certificate.pfx", password);
Enter fullscreen mode Exit fullscreen mode

Can I Remove Signatures?

Yes, but it invalidates the signature:

var pdf = PdfDocument.FromFile("signed.pdf", ownerPassword);

// Removing a signature breaks cryptographic validity
// Only do this if you have authority
Enter fullscreen mode Exit fullscreen mode

Signatures are designed to be tamper-evident. Removing them alerts viewers that the document was modified.

How Do I Sign Generated PDFs?

Sign immediately after creation:

var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Invoice #12345</h1>");

pdf.SignWithFile("invoice-cert.pfx", "password");

using var signatureImage = new Bitmap("company-sig.png");
pdf.DrawBitmap(signatureImage, 400, 100, 0);

pdf.SaveAs("invoice-12345-signed.pdf");
Enter fullscreen mode Exit fullscreen mode

No intermediate unsigned file. Secure from generation.

What About E-Signature Compliance?

Digital signatures with IronPDF meet:

  • ESIGN Act (USA)
  • eIDAS (Europe)
  • UETA (Uniform Electronic Transactions Act)

For full compliance, maintain audit logs, consent records, and signer authentication.


Written by Jacob Mellor, CTO at Iron Software. Jacob created IronPDF and leads a team of 50+ engineers building .NET document processing libraries.

Top comments (0)