Articles in this section
Category / Section

How to sign a PDF document without showing the signature

6 mins read

The Syncfusion Essential® PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can sign a PDF document without showing the signature.

Steps to sign a PDF document without showing the signature:

  1. Create a new C# console application project.

Create C# console application

  1. Install the Syncfusion.Pdf.WinForms NuGet package as reference to your .NET Framework application from the NuGet.org.

 NuGet package reference

  1. Include the following namespaces in the Program.cs file.

C#

using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf.Security;
using System.Drawing;

 

VB.NET

Imports Syncfusion.Pdf
Imports Syncfusion.Pdf.Graphics
Imports Syncfusion.Pdf.Security
Imports System.Drawing 

 

  1. Use the following code snippet to sign a PDF document without showing the signature.

C#

//Create a new PDF document 
PdfDocument document = new PdfDocument();
//Adds a new page
PdfPageBase page = document.Pages.Add();
//Create graphics 
PdfGraphics graphics = page.Graphics;
//Creates a certificate instance from PFX file with private key
PdfCertificate pdfCert = new PdfCertificate(@"PDF.pfx", "syncfusion");
//Creates a digital signature
PdfSignature signature = new PdfSignature(document, page, pdfCert, "Signature");
//Sets an image for signature
PdfBitmap signatureImage = new PdfBitmap(@"logo.png");
//Sets signature information
signature.Bounds = new RectangleF(new PointF(0, 0), signatureImage.PhysicalDimension);
signature.ContactInfo = "johndoe@owned.us";
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am author of this document.";
signature.Certificated = true;
//Draws the signature image 
graphics.DrawImage(signatureImage, 0, 0);
//Save and close the document 
document.Save("Sample.pdf");
document.Close(true);
//This will open the PDF file so, the result will be seen in default PDF viewer
Process.Start("Sample.pdf");

 

VB.NET

'Create a New PDF document 
Dim document As PdfDocument = New PdfDocument()
'Adds a New page
Dim page As PdfPageBase = document.Pages.Add()
'Create graphics 
Dim graphics As PdfGraphics = page.Graphics
'Creates a certificate instance from PFX file with private key
Dim pdfCert As PdfCertificate = New PdfCertificate("PDF.pfx", "syncfusion")
'Creates a digital signature
Dim signature As PdfSignature = New PdfSignature(document, page, pdfCert, "Signature")
'Sets an image for signature
Dim signatureImage As PdfBitmap = New PdfBitmap("logo.png")
'Sets signature information
signature.Bounds = New RectangleF(New PointF(0, 0), signatureImage.PhysicalDimension)
signature.ContactInfo = "johndoe@owned.us"
signature.LocationInfo = "Honolulu, Hawaii"
signature.Reason = "I am author of this document."
signature.Certificated = True
'Draws the signature image 
graphics.DrawImage(signatureImage, 0, 0)
'Save And close the document
document.Save("Sample.pdf")
document.Close(True)
'This will open the PDF file so, the result will be seen in default PDF viewer
Process.Start("Sample.pdf")

 

A complete working sample can be downloaded from DigitalSignature_sample.zip.

 

By executing the program, you will get the PDF document as follows.

Output document screenshot

 

Take a moment to peruse the documentation, where you will find other options such as adding of digital signature, externally sign a PDF document, adding a signature validation, adding timestamp to PDF document, retrieve certificate details from existing PDF, enable LTV signature, digital signature with customization and digital signature validation.

 

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

 

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.


See Also:

Digitally sign an existing PDF document

Digitally sign PDF using X509Certificate

Digitally sign PDF document with external signature

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied