Comment signer des fichiers PDF en C# en utilisant IronPDF | Tutoriel IronPDF

Un guide du développeur pour la signature numérique des PDF avec C#

This article was translated from English: Does it need improvement?
Translated
View the article in English

Ce guide complet montre aux développeurs C# comment signer numériquement des PDF à l'aide d'IronPdf, couvrant les signatures basées sur des certificats, les tampons visuels et les champs de formulaire interactifs pour garantir l'authenticité et la sécurité des documents.

Ajouter une signature à un document PDF est une exigence courante dans de nombreuses applications, mais 'signer' peut signifier des choses différentes. Pour certains, il s'agit d'appliquer une signature numérique inviolable à l'aide d'un certificat de sécurité. Pour d'autres, il peut s'agir d'apposer une image de signature manuscrite visuelle sur un document ou d'ajouter un champ de formulaire interactif pour permettre aux utilisateurs de signer électroniquement.

Ce guide fournit un aperçu complet pour les développeurs C# sur la manière d'accomplir toutes ces tâches à l'aide de la bibliothèque IronPDF pour .NET. Nous couvrirons tout, de l'application d'une signature numérique sécurisée X509Certificate2 à l'apposition de signatures graphiques et à la création de champs de signature interactifs, en garantissant que vos documents PDF sont authentiques, sécurisés et professionnels.

Démarrage rapide : Signer numériquement un PDF sans effort à l'aide de IronPDF

Commencez rapidement avec IronPDF pour signer numériquement vos documents PDF en utilisant un processus simple et direct. Cet exemple démontre comment utiliser un certificat .pfx pour authentifier et signer un fichier PDF, garantissant l'intégrité et l'authenticité du document. Suivez ces étapes pour intégrer de manière transparente la signature numérique dans votre application.

Nuget IconCommencez dès maintenant à créer des PDF avec NuGet :

  1. Installez IronPDF avec le gestionnaire de packages NuGet

    PM > Install-Package IronPdf

  2. Copiez et exécutez cet extrait de code.

    new IronPdf.Signing.PdfSignature("certificate.pfx", "password").SignPdfFile("input.pdf");
  3. Déployez pour tester sur votre environnement de production.

    Commencez à utiliser IronPDF dans votre projet dès aujourd'hui grâce à un essai gratuit.
    arrow pointer

Comment appliquer une signature numérique à un PDF avec un certificat ?

Vous pouvez appliquer une signature numérique à un document PDF à l'aide d'un fichier de certificat numérique (tel que .pfx ou .p12) pour garantir l'authenticité et l'intégrité du document. Ce processus garantit que le document n'a pas été modifié depuis sa signature. Pour un aperçu complet des capacités de signature numérique, explorez notre guide complet sur les signatures numériques.

IronPDF fournit une API simple pour cela, prenant en charge plusieurs façons de définir une signature numérique. Le cœur de cette fonctionnalité repose sur la classe PdfSignature, qui encapsule le certificat et toutes les métadonnées associées pour la signature.

Méthode de signature Description du projet
Sign Signe un PDF avec un objet PdfSignature que vous créez et configurez.
SignWithFile Signe un PDF à l'aide d'un fichier de certificat de signature numérique (.pfx ou .p12) situé sur le disque.
SignWithStore Signe un PDF avec une signature numérique provenant du magasin de certificats de votre ordinateur, identifiée par son thumbprint ID.

Utilisation d'un objet X509Certificat2

Pour un maximum de contrôle, vous pouvez créer un objet X509Certificate2 à partir de votre fichier de certificat. IronPDF est entièrement conforme à la norme X509Certificate2, offrant une méthode robuste et sécurisée pour la mise en œuvre de signature numérique. Lors de la création de l'objet certificat, assurez-vous que les X509KeyStorageFlags sont définis sur Exportable, car cela est requis par les API cryptographiques sous-jacentes. Consultez des exemples pratiques de signatures numériques dans notre dépôt de code.

Install-Package IronPdf
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;

// Create a new PDF from an HTML string for demonstration.
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Signed Document</h1><p>This document has been digitally signed.</p>");

// Load the certificate from a .pfx file with its password.
// The X509KeyStorageFlags.Exportable flag is crucial for allowing the private key to be used in the signing process.
var cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);

// Create a PdfSignature object using the loaded certificate.
var signature = new PdfSignature(cert);

// Apply the signature to the PDF document.
pdf.Sign(signature);

// Save the securely signed PDF document.
pdf.SaveAs("Signed.pdf");
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;

// Create a new PDF from an HTML string for demonstration.
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Signed Document</h1><p>This document has been digitally signed.</p>");

// Load the certificate from a .pfx file with its password.
// The X509KeyStorageFlags.Exportable flag is crucial for allowing the private key to be used in the signing process.
var cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);

// Create a PdfSignature object using the loaded certificate.
var signature = new PdfSignature(cert);

// Apply the signature to the PDF document.
pdf.Sign(signature);

// Save the securely signed PDF document.
pdf.SaveAs("Signed.pdf");
$vbLabelText   $csharpLabel

Le code ci-dessus génère d'abord un PDF simple. Il charge ensuite un fichier de certificat .pfx dans un objet X509Certificate2. Cet objet, qui représente l'identité numérique, est passé au constructeur PdfSignature. Enfin, la méthode pdf.Sign applique cette signature au document avant de l'enregistrer. For more information on the X509Certificate2 class, you can refer to the official Microsoft documentation.

Ajout de détails granulaires à une signature numérique

Une signature numérique peut contenir plus que le certificat ; vous pouvez intégrer des métadonnées riches pour fournir un contexte à la signature. Cela inclut l'emplacement de la signature, le motif, les informations de contact et un horodatage sécurisé d'une autorité de confiance. Vous pouvez également définir et modifier les métadonnées pour des propriétés de document supplémentaires.

Ajouter ces détails améliore la traçabilité du document et fournit aux vérificateurs des informations précieuses. IronPDF prend également en charge les serveurs d'horodatage utilisant les algorithmes de hachage modernes SHA256 et SHA512.

using IronPdf;
using IronPdf.Signing;
using IronSoftware.Drawing;
using System;

// Load an existing PDF document to be signed.
var pdf = PdfDocument.FromFile("invoice.pdf");

// Create a PdfSignature object directly from the certificate file and password.
var signature = new PdfSignature("IronSoftware.pfx", "123456");

// Add detailed metadata to the signature for a comprehensive audit trail.
// These properties enhance the signature's credibility and provide context
signature.SignatureDate = DateTime.Now;
signature.SigningContact = "legal@ironsoftware.com";
signature.SigningLocation = "Chicago, USA";
signature.SigningReason = "Contractual Agreement";

// Add a secure timestamp from a trusted Time Stamp Authority (TSA).
// This provides cryptographic proof of the signing time.
signature.TimeStampUrl = new Uri("[http://timestamp.digicert.com](http://timestamp.digicert.com)");
signature.TimestampHashAlgorithm = TimestampHashAlgorithms.SHA256;

// Apply a visual appearance to the signature. (More on this in the next section)
signature.SignatureImage = new PdfSignatureImage("assets/visual-signature.png", 0, new Rectangle(350, 750, 200, 100));

// Sign the PDF document with the configured signature object.
pdf.Sign(signature);

// Save the final, signed PDF document.
pdf.SaveAs("DetailedSignature.pdf");
using IronPdf;
using IronPdf.Signing;
using IronSoftware.Drawing;
using System;

// Load an existing PDF document to be signed.
var pdf = PdfDocument.FromFile("invoice.pdf");

// Create a PdfSignature object directly from the certificate file and password.
var signature = new PdfSignature("IronSoftware.pfx", "123456");

// Add detailed metadata to the signature for a comprehensive audit trail.
// These properties enhance the signature's credibility and provide context
signature.SignatureDate = DateTime.Now;
signature.SigningContact = "legal@ironsoftware.com";
signature.SigningLocation = "Chicago, USA";
signature.SigningReason = "Contractual Agreement";

// Add a secure timestamp from a trusted Time Stamp Authority (TSA).
// This provides cryptographic proof of the signing time.
signature.TimeStampUrl = new Uri("[http://timestamp.digicert.com](http://timestamp.digicert.com)");
signature.TimestampHashAlgorithm = TimestampHashAlgorithms.SHA256;

// Apply a visual appearance to the signature. (More on this in the next section)
signature.SignatureImage = new PdfSignatureImage("assets/visual-signature.png", 0, new Rectangle(350, 750, 200, 100));

// Sign the PDF document with the configured signature object.
pdf.Sign(signature);

// Save the final, signed PDF document.
pdf.SaveAs("DetailedSignature.pdf");
$vbLabelText   $csharpLabel

Vous remarquerez peut-être une icône d'avertissement dans certains visionneuses PDF si le certificat de signature n'est pas dans le magasin de confiance du système. Pour obtenir une coche verte, le certificat doit être ajouté aux identités de confiance du visionneuse.

Comment puis-je ajouter une représentation visuelle à une signature numérique ?

Bien qu'une signature numérique soit cryptographiquement intégrée au PDF, il est souvent utile d'avoir une représentation visuelle sur la page. Cela peut être un logo d'entreprise, une image de signature manuscrite ou d'autres graphiques. IronPDF facilite l'ajout d'une image à un objet PdfSignature.

Vous pouvez charger une image à partir d'un fichier ou d'un flux et la positionner précisément sur n'importe quelle page du PDF. Les formats d'image pris en charge sont les suivants : PNG, JPEG, GIF, BMP, TIFF et WebP. Cette technique est similaire à la façon dont vous pourriez estampiller du texte et des images sur des documents PDF.

using IronPdf.Signing;
using IronSoftware.Drawing;

// This example demonstrates various ways to add a visual image to a PDF signature.

// Create a PdfSignature object.
var signature = new PdfSignature("IronSoftware.pfx", "123456");

// Define the position and size for the signature image on the first page (index 0).
// Rectangle parameters: x position, y position, width, height
var signatureRectangle = new Rectangle(350, 750, 200, 100);

// Option 1: Set the SignatureImage property directly.
// This is the most straightforward approach
signature.SignatureImage = new PdfSignatureImage("assets/visual-signature.png", 0, signatureRectangle);

// Option 2: Use the LoadSignatureImageFromFile method.
// This method provides the same functionality with a different syntax
signature.LoadSignatureImageFromFile("assets/visual-signature.png", 0, signatureRectangle);

// Option 3: Load an image from a stream. This is useful for images generated in memory.
// Perfect for scenarios where images are retrieved from databases or web services
AnyBitmap image = AnyBitmap.FromFile("assets/visual-signature.png");
using (var imageStream = image.ToStream())
{
    signature.LoadSignatureImageFromStream(imageStream, 0, signatureRectangle);
}

// After configuring the signature image, apply it to a PDF.
var pdf = PdfDocument.FromFile("invoice.pdf");
pdf.Sign(signature);
pdf.SaveAs("VisualSignature.pdf");
using IronPdf.Signing;
using IronSoftware.Drawing;

// This example demonstrates various ways to add a visual image to a PDF signature.

// Create a PdfSignature object.
var signature = new PdfSignature("IronSoftware.pfx", "123456");

// Define the position and size for the signature image on the first page (index 0).
// Rectangle parameters: x position, y position, width, height
var signatureRectangle = new Rectangle(350, 750, 200, 100);

// Option 1: Set the SignatureImage property directly.
// This is the most straightforward approach
signature.SignatureImage = new PdfSignatureImage("assets/visual-signature.png", 0, signatureRectangle);

// Option 2: Use the LoadSignatureImageFromFile method.
// This method provides the same functionality with a different syntax
signature.LoadSignatureImageFromFile("assets/visual-signature.png", 0, signatureRectangle);

// Option 3: Load an image from a stream. This is useful for images generated in memory.
// Perfect for scenarios where images are retrieved from databases or web services
AnyBitmap image = AnyBitmap.FromFile("assets/visual-signature.png");
using (var imageStream = image.ToStream())
{
    signature.LoadSignatureImageFromStream(imageStream, 0, signatureRectangle);
}

// After configuring the signature image, apply it to a PDF.
var pdf = PdfDocument.FromFile("invoice.pdf");
pdf.Sign(signature);
pdf.SaveAs("VisualSignature.pdf");
$vbLabelText   $csharpLabel

Ce code montre trois façons équivalentes d'ajouter un composant visuel à une signature numérique. Que vous ayez une image sur disque ou en mémoire, vous pouvez facilement l'estampiller sur le PDF dans le cadre du processus de signature. Cela comble le fossé entre la sécurité cryptographique invisible et l'approbation visible du document.

Comment puis-je contrôler les autorisations documentaires après la signature ?

Lorsque vous signez un document, vous souhaitez peut-être spécifier quelles modifications, le cas échéant, sont autorisées par la suite. Par exemple, vous pouvez verrouiller complètement le document ou permettre uniquement aux utilisateurs de remplir les champs de formulaire. IronPDF vous permet de définir ces autorisations à l'aide de l'énumération SignaturePermissions. Pour un contrôle des autorisations plus avancé, consultez notre guide sur la définition des mots de passe et des autorisations PDF.

Définir les autorisations de signature est une partie clé de la gestion du cycle de vie d'un document. Cela garantit que l'intégrité du document est maintenue selon vos règles après l'application de votre signature. Si un utilisateur exécute une action non autorisée, la signature sera invalidée.

SignaturePermissions Membre Définition
NoChangesAllowed Aucune modification n'est autorisée. Le document est effectivement verrouillé.
FormFillingAllowed Seuls le remplissage des champs de formulaire existants et la signature sont autorisés.
AnnotationsAndFormFillingAllowed Permet de remplir des formulaires, de signer et de créer ou de modifier des annotations.

Saving and Signing a Specific PDF Revision

PDFs can store a history of changes, much like a version control system. This is known as incremental saving. When you sign a PDF, the signature applies to a specific revision of the document. This is crucial for workflows where a document goes through multiple stages of approval. Learn more about managing PDF revision history in our detailed guide.

In the following example, we load a PDF, make edits, and then sign the current revision while allowing only form-filling as a future change. We use SaveAsRevision to commit the current state to the document's history before saving the file.

using IronPdf.Signing;

// Load a PDF file with change tracking enabled.
// This enables incremental save functionality for revision management
var pdf = PdfDocument.FromFile("annual_census.pdf", ChangeTrackingModes.EnableChangeTracking);

// Placeholder for edits: You might add text, fill forms, or add annotations here.
// For example: pdf.Annotations.Add(new TextAnnotation(...));
// Or: pdf.Form["fieldName"].Value = "New Value";

// Sign the current state of the document using SignWithFile for convenience.
// We set permissions to allow further signatures and form filling.
pdf.SignWithFile(
    "assets/IronSignature.p12", 
    "password", 
    SignaturePermissions.AdditionalSignaturesAndFormFillingAllowed);

// Save the current state as a distinct revision within the PDF's history.
// This creates a snapshot that can be referenced later
PdfDocument pdfWithRevision = pdf.SaveAsRevision();

// Save the final PDF with its full revision history to a new file.
pdfWithRevision.SaveAs("annual_census_signed.pdf");
using IronPdf.Signing;

// Load a PDF file with change tracking enabled.
// This enables incremental save functionality for revision management
var pdf = PdfDocument.FromFile("annual_census.pdf", ChangeTrackingModes.EnableChangeTracking);

// Placeholder for edits: You might add text, fill forms, or add annotations here.
// For example: pdf.Annotations.Add(new TextAnnotation(...));
// Or: pdf.Form["fieldName"].Value = "New Value";

// Sign the current state of the document using SignWithFile for convenience.
// We set permissions to allow further signatures and form filling.
pdf.SignWithFile(
    "assets/IronSignature.p12", 
    "password", 
    SignaturePermissions.AdditionalSignaturesAndFormFillingAllowed);

// Save the current state as a distinct revision within the PDF's history.
// This creates a snapshot that can be referenced later
PdfDocument pdfWithRevision = pdf.SaveAsRevision();

// Save the final PDF with its full revision history to a new file.
pdfWithRevision.SaveAs("annual_census_signed.pdf");
$vbLabelText   $csharpLabel

Understanding incremental saves is key to advanced PDF workflows. While a simple viewer might only show the latest version, a tool like Adobe Acrobat can reveal the entire revision history, showing who signed which version and what changes were made between signatures. IronPDF gives you full programmatic control over this process.

For businesses managing complex document workflows that require high security and compliance, a comprehensive solution may be needed. Iron Software offers Iron Suite, which includes IronPDF for signing and manipulation, plus other libraries for a wide range of document processing tasks, available for a single one-time payment.

How Can I Manage and Verify Signatures Across Revisions?

A PDF document can have multiple signatures applied across its various revisions. IronPDF provides tools to manage this history effectively.

  • Roll Back to a Previous Revision: You can revert a document to an earlier state using the GetRevision method. This will discard all changes and signatures made after that revision.
  • Verify All Signatures: The VerifySignatures method checks the validity of all signatures across all revisions of the document. It returns true only if every signature is valid and no unauthorized changes have been made.
  • Remove Signatures: The RemoveSignatures method will strip all digital signatures from every revision of the document, creating a clean, unsigned version.
// Load a PDF with a complex signature history.
var pdf = PdfDocument.FromFile("multi_signed_report.pdf");

// Verify all signatures across all revisions.
// This ensures document integrity throughout its entire history
bool allSignaturesValid = pdf.VerifySignatures();
Console.WriteLine($"All signatures are valid: {allSignaturesValid}");

// Roll back to the first revision (index 0).
// Useful for reviewing the original document state
if (pdf.RevisionCount &gt; 1)
{
    PdfDocument firstRevision = pdf.GetRevision(0);
    firstRevision.SaveAs("report_first_revision.pdf");
}

// Create a completely unsigned version of the document.
// This removes all digital signatures while preserving content
pdf.RemoveSignatures();
pdf.SaveAs("report_unsigned.pdf");
// Load a PDF with a complex signature history.
var pdf = PdfDocument.FromFile("multi_signed_report.pdf");

// Verify all signatures across all revisions.
// This ensures document integrity throughout its entire history
bool allSignaturesValid = pdf.VerifySignatures();
Console.WriteLine($"All signatures are valid: {allSignaturesValid}");

// Roll back to the first revision (index 0).
// Useful for reviewing the original document state
if (pdf.RevisionCount &gt; 1)
{
    PdfDocument firstRevision = pdf.GetRevision(0);
    firstRevision.SaveAs("report_first_revision.pdf");
}

// Create a completely unsigned version of the document.
// This removes all digital signatures while preserving content
pdf.RemoveSignatures();
pdf.SaveAs("report_unsigned.pdf");
$vbLabelText   $csharpLabel

How Do I Stamp a Handwritten Signature onto a PDF?

Sometimes, you don't need the cryptographic security of a digital signature but simply want to apply a visual, electronic signature, like a scanned handwritten signature. This is often referred to as stamping. IronPDF can do this using its Watermark or Stamp features. For more advanced watermarking options, explore our custom watermarks guide.

Let's start with a sample invoice PDF and a .png image of a handwritten signature.

The original invoice PDF before stamping a signature.

Here is the signature image we will apply:

Handwritten signature sample showing 'IRON' in black ink for PDF stamping tutorial A sample handwritten signature image.

The following code uses the Watermark property to stamp this image onto the bottom-right corner of the PDF.

using IronPdf.Editing;

// Load the existing PDF document.
var pdf = PdfDocument.FromFile("invoice.pdf");

// Create an HtmlStamp containing our signature image.
// HtmlStamp allows us to position HTML content precisely on the page
var signatureStamp = new HtmlStamp("&lt;img src='assets/signature.png'/&gt;")
{
    // Configure the stamp's position and appearance.
    VerticalAlignment = VerticalAlignment.Bottom,
    HorizontalAlignment = HorizontalAlignment.Right,
    Margin = 10,  // Add some space from the edge.
    Opacity = 90  // Make it slightly transparent for a more authentic look.
};

// Apply the stamp to all pages of the PDF.
// You can also specify specific page numbers if needed
pdf.ApplyStamp(signatureStamp);

// Save the modified PDF document.
pdf.SaveAs("official_invoice.pdf");
using IronPdf.Editing;

// Load the existing PDF document.
var pdf = PdfDocument.FromFile("invoice.pdf");

// Create an HtmlStamp containing our signature image.
// HtmlStamp allows us to position HTML content precisely on the page
var signatureStamp = new HtmlStamp("&lt;img src='assets/signature.png'/&gt;")
{
    // Configure the stamp's position and appearance.
    VerticalAlignment = VerticalAlignment.Bottom,
    HorizontalAlignment = HorizontalAlignment.Right,
    Margin = 10,  // Add some space from the edge.
    Opacity = 90  // Make it slightly transparent for a more authentic look.
};

// Apply the stamp to all pages of the PDF.
// You can also specify specific page numbers if needed
pdf.ApplyStamp(signatureStamp);

// Save the modified PDF document.
pdf.SaveAs("official_invoice.pdf");
$vbLabelText   $csharpLabel

What Does the Stamped PDF Result Look Like?

After running the code, the signature image is stamped onto the document, creating a visually signed invoice.

The final PDF with the handwritten signature image stamped in the bottom-right corner.

How Can I Add an Interactive Signature Field to a PDF?

For documents that need to be signed by an end-user in a PDF viewer like Adobe Acrobat, you can add an interactive signature form field. This creates an empty, clickable area that prompts the user to apply their own digital signature. For a complete guide on PDF forms, see our creating PDF forms tutorial.

You can create a SignatureFormField and add it to the PDF's form collection. You have precise control over its location and size on the page. This is particularly useful for documents that require multiple signatures or when you need to collect signatures from external parties.

using IronPdf.Forms;
using IronSoftware.Drawing;

// Create a new PDF to add the signature field to.
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Veuillez signer ci-dessous</h1>");

// Define the properties for the signature form field.
string fieldName = "ClientSignature";  // Unique identifier for the field
int pageIndex = 0;  // Add to the first page (zero-indexed)
var fieldRect = new Rectangle(50, 200, 300, 100);  // Position: (x, y), Size: (width, height)

// Create the SignatureFormField object.
// This creates an interactive field that users can click to sign
var signatureField = new SignatureFormField(fieldName, pageIndex, fieldRect);

// Add the signature field to the PDF's form.
pdf.Form.Add(signatureField);

// Save the PDF with the new interactive signature field.
pdf.SaveAs("interactive_signature.pdf");
using IronPdf.Forms;
using IronSoftware.Drawing;

// Create a new PDF to add the signature field to.
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Veuillez signer ci-dessous</h1>");

// Define the properties for the signature form field.
string fieldName = "ClientSignature";  // Unique identifier for the field
int pageIndex = 0;  // Add to the first page (zero-indexed)
var fieldRect = new Rectangle(50, 200, 300, 100);  // Position: (x, y), Size: (width, height)

// Create the SignatureFormField object.
// This creates an interactive field that users can click to sign
var signatureField = new SignatureFormField(fieldName, pageIndex, fieldRect);

// Add the signature field to the PDF's form.
pdf.Form.Add(signatureField);

// Save the PDF with the new interactive signature field.
pdf.SaveAs("interactive_signature.pdf");
$vbLabelText   $csharpLabel

When a user opens this PDF, they will see a clickable field, allowing them to complete the signing process using their own digital ID. You can learn more about creating and managing interactive forms in our How-To guide on creating PDF forms.

PDF editor showing unsigned signature field with 'Click to sign' prompt in document titled 'testing' An unsigned, interactive signature field added programmatically to a PDF document.

How Do I Retrieve the Signer Name from Verified Signatures?

To obtain the common name of the certificate owner who signed a signature, we can use the VerifiedSignature class to access the SignerName property. Below is a code snippet demonstrating how to accomplish this.

:path=/static-assets/pdf/content-code-examples/how-to/signing-find-signer-name.cs
using IronPdf;
using System;

// Import the Signed PDF report
var pdf = PdfDocument.FromFile("multi_signed_report.pdf");

// Using GetVerifiedSignatures() obtain a list of `VerifiedSignature` objects from the PDF
pdf.GetVerifiedSignatures().ForEach(signature =>
{
    // Print out the SignerName of each `VerifiedSignature` object
    Console.WriteLine($"SignatureName: {signature.SignerName}");
});
$vbLabelText   $csharpLabel

Après avoir importé le fichier PDF signé, nous utilisons la méthode GetVerifiedSignatures pour récupérer une liste d'objets VerifiedSignature dans le rapport et imprimer le SignerName pour chaque signature.

Veuillez noter que cette valeur est extraite du Subject Distinguished Name (SubjectDN) du certificat et qu'elle renverra un résultat nul si le champ CN n'est pas présent.

Quelles sont les prochaines étapes de la signature de PDF avec IronPDF ?

Ce guide a démontré les capacités puissantes et flexibles de signature de PDF d'IronPDF. Que vous ayez besoin d'appliquer des signatures numériques sécurisées avec des métadonnées détaillées, de gérer les révisions de documents, d'apposer des signatures visuelles ou de créer des formulaires interactifs, IronPDF fournit une API complète et conviviale pour les développeurs.

Pour poursuivre votre exploration, vous pouvez télécharger la bibliothèque IronPDF pour .NET et obtenir une licence d'essai gratuite pour tester toutes ses fonctionnalités dans vos projets. Pour des techniques de manipulation de documents plus avancées, notamment l'ajout d'annotations et le travail avec des champs de formulaire, consultez notre documentation complète et nos tutoriels.

Prêt à voir ce que vous pouvez faire d'autre ? Consultez notre page de didacticiels ici : Signer et sécuriser des PDF

Questions Fréquemment Posées

Comment signer numériquement un PDF à l'aide d'un certificat en C# ?

Avec IronPDF, vous pouvez signer numériquement un PDF en une seule ligne de code à l'aide de la classe PdfSignature. Il suffit de créer un nouvel objet PdfSignature avec votre fichier de certificat (.pfx ou .p12) et votre mot de passe, puis d'appeler la méthode SignPdfFile(). Par exemple : new IronPdf.Signing.PdfSignature("certificate.pfx", "password").SignPdfFile("input.pdf"). Cette méthode applique une signature numérique infalsifiable à l'aide de votre certificat X5092 pour garantir l'authenticité du document.

Quels sont les types de signatures PDF pris en charge ?

IronPDF prend en charge trois principaux types de signatures PDF : 1) les signatures numériques utilisant des certificats X509Certificate2 pour l'authentification et l'inviolabilité, 2) les tampons de signature visuelle qui ajoutent des images de signature graphique ou manuscrite aux documents, et 3) les champs de formulaire de signature interactive qui permettent aux utilisateurs de signer électroniquement les PDF. Chaque type de signature répond à des besoins différents en matière de sécurité des documents et de flux de travail.

Quels formats de certificats peuvent être utilisés pour la signature numérique ?

IronPDF prend en charge les formats de certificats numériques courants, notamment les fichiers .pfx (Personal Information Exchange) et .p12. Ces fichiers de certificat contiennent à la fois la clé publique et la clé privée nécessaires à la signature numérique. La classe PdfSignature d'IronPDF peut fonctionner avec n'importe quel objet X509Certificate2, ce qui offre une certaine souplesse dans la manière dont vous chargez et gérez vos certificats de signature.

Puis-je ajouter une représentation visuelle à ma signature numérique ?

Oui, IronPDF vous permet d'ajouter des éléments visuels à vos signatures numériques. Vous pouvez inclure une représentation graphique telle qu'une image de signature manuscrite, un logo d'entreprise ou un cachet personnalisé à côté de la signature cryptographique. Cela permet de combiner la sécurité des certificats numériques avec une confirmation visuelle, ce qui rend les documents signés à la fois sûrs et présentables d'un point de vue professionnel.

Comment créer un champ de signature interactif pour que les utilisateurs puissent signer électroniquement ?

IronPDF vous permet d'ajouter des champs de formulaire de signature interactive aux documents PDF. Ces champs permettent aux utilisateurs de signer électroniquement les documents en cliquant et en dessinant leur signature ou en téléchargeant une image de signature. Cette fonction est idéale pour créer des documents qui nécessitent une collecte de signatures, tels que des contrats ou des formulaires qui doivent être signés par plusieurs parties.

La signature d'un PDF garantit-elle l'intégrité du document ?

Oui, lorsque vous signez numériquement un PDF à l'aide d'IronPDF avec un certificat X5092, cela crée un sceau inviolable qui garantit l'intégrité du document. La signature numérique garantit que le document n'a pas été modifié depuis sa signature. Toute modification apportée au PDF après la signature invalidera la signature, ce qui alertera les destinataires que le document a pu être compromis.

Jacob Mellor, Directeur technique @ Team Iron
Directeur technique

Jacob Mellor est directeur technique chez Iron Software et un ingénieur visionnaire pionnier dans la technologie des PDF en C#. En tant que développeur original derrière la base de code principale d'Iron Software, il a façonné l'architecture du produit de l'entreprise depuis sa création, ...

Lire la suite
Revu par
Jeff Fritz
Jeffrey T. Fritz
Responsable principal du programme - Équipe de la communauté .NET
Jeff est également responsable principal du programme pour les équipes .NET et Visual Studio. Il est le producteur exécutif de la série de conférences virtuelles .NET Conf et anime 'Fritz and Friends', une diffusion en direct pour développeurs qui est diffusée deux fois par semaine où il parle de technologie et écrit du code avec les téléspectateurs. Jeff écrit des ateliers, des présentations et prévoit du contenu pour les plus grands événements de développement Microsoft, y compris Microsoft Build, Microsoft Ignite, .NET Conf et le sommet Microsoft MVP
Prêt à commencer?
Nuget Téléchargements 17,012,929 | Version : 2025.12 vient de sortir