How to digitally sign PDF in C# and VB.NET? | Syncfusion (2024)

PDF documents are digitally signed using x509 certificates such as .pfx files with private keys and support for Hardware Security Module (HSM), Online Certificate Status Protocol (OCSP), Certificate Revocation List (CRL), and Windows Certificate Store to offer authenticity and integrity.

Syncfusion Essential PDF is a .NET PDF Libraryused to create, read, and edit PDF documents. Using this library, you can add digital signature to the PDF document using X509Certificate2 class object in C# and VB.NET.

Steps to digitally sign a PDF document using X509Certificate2 class object programmatically:

  1. Create a new C# console application project. How to digitally sign PDF in C# and VB.NET? | Syncfusion (1)
  2. Install the Syncfusion.Pdf.WinForms NuGet package as reference to your .NET Framework application from NuGet.org. How to digitally sign PDF in C# and VB.NET? | Syncfusion (2)
  3. Include the following namespace in the Program.cs file.

C#

VB.NET

Imports Syncfusion.PdfImports Syncfusion.Pdf.GraphicsImports Syncfusion.Pdf.SecurityImports System.Drawing
  1. Use the following code snippet to add a digital signature in the PDF document.

C#

// Creates a new PDF documentPdfDocument document = new PdfDocument();//Adds a new pagePdfPageBase page = document.Pages.Add();PdfGraphics graphics = page.Graphics;//Creating a X509Certificate2 instance from PFX file with private keyX509Certificate2 cert = new X509Certificate2("pdf.pfx", "syncfusion");//Creating PdfCertificate object with X509Certificate2 class objectPdfCertificate pdfCert = new PdfCertificate(cert);//Creates a digital signaturePdfSignature signature = new PdfSignature(document, page, pdfCert, "Signature");//Sets an image for signature fieldPdfBitmap signatureImage = new PdfBitmap(@"signature.png");//Sets signature informationsignature.Bounds = new RectangleF(0, 0, 200, 100);signature.ContactInfo = "[email protected]";signature.LocationInfo = "Honolulu, Hawaii";signature.Reason = "I am author of this document.";//Draws the signature imagegraphics.DrawImage(signatureImage, signature.Bounds);//Save the documentdocument.Save("Signature.pdf");//Close the documentdocument.Close(true);//This will open the PDF file so, the result will be seen in default PDF ViewerProcess.Start("Signature.pdf");

VB.NET

'Creates a new PDF documentDim document As New PdfDocument()'Adds a new pageDim page As PdfPageBase = document.Pages.Add()Dim graphics As PdfGraphics = page.Graphics'Creating a X509Certificate2 instance from PFX file with private keyDim cert As New X509Certificate2("pdf.pfx", "syncfusion")'Creating PdfCertificate object with X509Certificate2 class objectDim pdfCert As New PdfCertificate(cert)'Creates a digital signatureDim signature As New PdfSignature(document, page, pdfCert, "Signature")'Sets an image for signature fieldDim signatureImage As New PdfBitmap("signature.png")'Sets signature informationsignature.Bounds = New RectangleF(0, 0, 200, 100)signature.ContactInfo = "[email protected]"signature.LocationInfo = "Honolulu, Hawaii"signature.Reason = "I am author of this document."'Draws the signature imagegraphics.DrawImage(signatureImage, signature.Bounds)'Save the documentdocument.Save("Signature.pdf")'Close the documentdocument.Close(True)'This will open the PDF file so, the result will be seen in default PDF ViewerProcess.Start("Signature.pdf")

Download the working sample from DigitalSignature.zip

By executing the program, you will get the PDF document as follows. How to digitally sign PDF in C# and VB.NET? | Syncfusion (3)

Take a moment to peruse the documentation, where you can find other options like adding a digital signature using stream, signing an existing document, adding a timestamp in digital signature and features like protect PDF documents with code examples.

Refer here to explore the rich set of Syncfusion Essential PDF features.

An online sample link to generate Digitally signed PDF document

Note:

Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.

Conclusion

I hope you enjoyedlearning on How to digitally sign PDF using X509Certificate2 in C# and VB.NET.

You can refer to ourWinForms PDFfeature tourpage to know about its othergroundbreaking feature representationsanddocumentation,and how toquickly get started for configuration specifications. You can also exploreourWinForms PDF exampleto understand how to create and manipulate data.For current customers,you can check out ourcomponentsfrom theLicense and Downloadspage.If you are new to Syncfusion, you can try our 30-dayfree trialto check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below.You can also contact us through oursupport forums,Direct-Trac, orfeedback portal. We are always happy to assist you!

How to digitally sign PDF in C# and VB.NET? | Syncfusion (2024)

FAQs

How to digitally sign PDF in C# and VB.NET? | Syncfusion? ›

If you can't e-sign the document or even type in the fillable fields, the file could be set to read-only mode. This file protection mode prevents any changes, which might be why you can't sign a PDF. Here's how to check your file settings: Windows: Right-click on your PDF file and select Properties.

How to create a digital signature in ASP.NET C#? ›

Here's a step-by-step guide on how to use ASP.NET Core for creating digital signatures:
  1. Step 1: Set Up Your ASP.NET Core Project. ...
  2. Step 2: Add Cryptographic Libraries. ...
  3. Step 3: Generate Key Pairs. ...
  4. Step 4: Sign Documents. ...
  5. Step 5: Verify Digital Signatures. ...
  6. Step 6: Integrate with Your ASP.NET Core Application.
Sep 7, 2023

How do I digitally sign a PDF PDF? ›

See how to sign a PDF
  1. Open the PDF document and select Sign from the top tools bar. ...
  2. Create your signature and initials if not already done. ...
  3. From the Sign panel, select your signature, move over to the field where you want to add it, and then click to place the signature. ...
  4. The form fields are detected automatically.
Feb 25, 2024

How to digitally sign a PDF programmatically? ›

How to add Digital PDF Signature in C#
  1. Install C# library to add digital signature to PDFs.
  2. Use Window form to better visual the process.
  3. Pass digital signature and private password to PdfSignature class.
  4. Use SignPdfFile method to open and sign existing PDF.
  5. Check the signed PDF in the directory specified in step 4.
Jan 22, 2024

How to add digital signature in PDF using iTextSharp C#? ›

Adding a Digital Signature to a PDF Using a PFX File And iTextSharp in C#
  1. Create a project and install the library. ...
  2. Loading the PDF Document. ...
  3. Loading the Digital Certificate. ...
  4. Initialize the PDF Stamper And Create the Signature Appearance. ...
  5. Adding the Digital Signature. ...
  6. Saving the Signed PDF.
Aug 8, 2023

How to verify digital signature in PDF using C#? ›

How to validate digitally signed PDF document using C# and VB.NET
  1. Validate the document modification.
  2. Validate the certificate chain.
  3. Ensure the signature with timestamp time.
  4. Check the revocation status of the certificate with OCSP and CRL.
  5. Ensure the multiple digital signatures.

How to implement or add a digital signature in a PDF file using asp net? ›

Steps to apply one or more digital signature to PDF document programmatically:
  1. Create a new C# ASP.NET Core Web application project.
  2. Select Web application pattern (Model-View-Controller) for the project.
  3. Install the Syncfusion. Pdf. ...
  4. A default controller with name HomeController.

Why can't I digitally sign a PDF? ›

If you can't e-sign the document or even type in the fillable fields, the file could be set to read-only mode. This file protection mode prevents any changes, which might be why you can't sign a PDF. Here's how to check your file settings: Windows: Right-click on your PDF file and select Properties.

How to digitally sign a PDF without Adobe? ›

How to Add a Signature to a PDF without Adobe on a PC
  1. Launch WPS PDF Editor. ...
  2. Click open to open desired file. ...
  3. Upload specific file. ...
  4. Select Comment the Add signature. ...
  5. On the POP-UP Box, add name or signature. ...
  6. Draw a signature or write it down. ...
  7. Click below as shown by the arrow. ...
  8. Select PDF Signature.
Jan 3, 2024

Can you digitally sign a fillable PDF? ›

To complete and sign PDF forms, open the form in Acrobat, and then select Sign from the global bar.

How do you check if a PDF is digitally signed? ›

Click on the Signature Properties button to check signature properties. In the signature Properties window click Show Signers Certificate button. Following screen will be displayed once you click on it. Initially you will get the summary of the Digital Signature in the certificate viewer window.

How do I add a digital signature to a PDF for free? ›

Questions? We have answers.
  1. Select Add signature in the Sign panel.
  2. In the signature panel that opens, click Image, then Select image to browse for an image of your handwritten signature. ...
  3. Drag your new electronic signature into a signature field or anywhere on the PDF. ...
  4. Download or share your signed document.

How do I enable digital signature in PDF online for free? ›

How to sign a PDF
  1. Create a free DocuSign eSignature account.
  2. Select “Start now”.
  3. Upload a PDF document that you want to sign.
  4. Check the “I'm the only signer” box.
  5. Click “Sign.”
  6. Drag and drop your signature from the left-hand navigation panel.
  7. Click Finish.

What is iTextSharp? ›

Itextsharp is an advanced tool library which is used for creating complex pdf repors. itext is used by different techonologies -- Android , . NET, Java and GAE developer use it to enhance their applications with PDF functionality.

How do I create my own digital signature? ›

You can create a digital signature using Adobe's e-signature solution. Simply click the review link and opt to digitally sign. From there, select a signature source and name, then sign in to apply your digital signature. Next, you can preview your signature and authenticate it if you are satisfied with how it looks.

What is the easiest way to create a digital signature? ›

Creating a digital signature is easy
  1. Upload your document into the electronic signature application, such as our DocuSign eSignature application.
  2. Drag in the signature, text and date fields where the recipient needs to take action.
  3. Click send.

How to create SHA256 RSA signature using C#? ›

Signing with SHA256 and RSA

In the Ch11_Cryptography class library project, add the following code to the Protector class: public static string PublicKey; public static string GenerateSignature(string data) { byte[] dataBytes = Encoding. Unicode. GetBytes(data); var sha = SHA256.

Top Articles
Luke 14:28 “Is there anyone here who, planning to build a new house, doesn’t first sit down and figure the cost so you’ll know if you can complete it? If you only get the foundation laid and then run out of mone For which of you, intending to build a towe
Google Gemini vs ChatGPT: Which AI Chatbot Wins in 2024?
Menards Thermal Fuse
Identifont Upload
Federal Fusion 308 165 Grain Ballistics Chart
Readyset Ochsner.org
Ventura Craigs List
360 Training Alcohol Final Exam Answers
Paketshops | PAKET.net
Kagtwt
Aries Auhsd
Craigslist Free Grand Rapids
Winterset Rants And Raves
Lenscrafters Huebner Oaks
The most iconic acting lineages in cinema history
This Modern World Daily Kos
Www Craigslist Com Phx
Chelactiv Max Cream
Hanger Clinic/Billpay
The best TV and film to watch this week - A Very Royal Scandal to Tulsa King
Wausau Obits Legacy
Unity - Manual: Scene view navigation
50 Shades Of Grey Movie 123Movies
Water Trends Inferno Pool Cleaner
MLB power rankings: Red-hot Chicago Cubs power into September, NL wild-card race
Music Go Round Music Store
Morristown Daily Record Obituary
Pecos Valley Sunland Park Menu
Evil Dead Rise Showtimes Near Regal Sawgrass & Imax
Jeff Nippard Push Pull Program Pdf
Lines Ac And Rs Can Best Be Described As
4Oxfun
Grave Digger Wynncraft
My Reading Manga Gay
Dentist That Accept Horizon Nj Health
Bursar.okstate.edu
Que Si Que Si Que No Que No Lyrics
After Transmigrating, The Fat Wife Made A Comeback! Chapter 2209 – Chapter 2209: Love at First Sight - Novel Cool
Best Workers Compensation Lawyer Hill & Moin
CVS Near Me | Somersworth, NH
Omnistorm Necro Diablo 4
Geology - Grand Canyon National Park (U.S. National Park Service)
Convenient Care Palmer Ma
Sam's Club Gas Prices Florence Sc
Union Corners Obgyn
Rocky Bfb Asset
Rush Copley Swim Lessons
Academic Notice and Subject to Dismissal
3500 Orchard Place
Rovert Wrestling
Naughty Natt Farting
Used Curio Cabinets For Sale Near Me
Latest Posts
Article information

Author: Allyn Kozey

Last Updated:

Views: 5900

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Allyn Kozey

Birthday: 1993-12-21

Address: Suite 454 40343 Larson Union, Port Melia, TX 16164

Phone: +2456904400762

Job: Investor Administrator

Hobby: Sketching, Puzzles, Pet, Mountaineering, Skydiving, Dowsing, Sports

Introduction: My name is Allyn Kozey, I am a outstanding, colorful, adventurous, encouraging, zealous, tender, helpful person who loves writing and wants to share my knowledge and understanding with you.