PM > Install-Package XDoc.PDF

How to Start Tutorials Troubleshooting Main Operations Convert PDF Read PDF Edit PDF PDF Report Generator Work with PDF Modules PDF Document PDF Pages Text Image Graph & Path Annotation, Markup & Drawing Redaction Security Digital Signature Forms Watermark Bookmark Link File Attachment File Metadata Printing Work with Other SDKs Barcode read Barcode create OCR Twain

C# PDF Document Process Library
How to add, remove, update PDF file digital signatures using C#.net


C# Solutions for Improving the Security of Your PDF File by Adding Digital Signatures in Visual C#.NET Class





In this C# tutorial, you learn how to manage PDF document digital signature

  • Add digital signature to PDF
  • Prepare a certification
  • Add a signature
  • Sign a PDF document

How to create digital signature for PDF document using C#

  1. Download XDoc.PDF digital signature manager C# library
  2. Install C# library to create digital signature for PDF file
  3. Step by Step Tutorial


























  • Best .NET framework PDF SDK library for PDF signature manipulation in Visual C# .NET WinForms and ASP.NET WebForm project
  • Provide free PDF signing application component to add signature to PDF file in C#.NET project
  • Able to use online C# source code to create a signature for PDF document in Visual Studio .NET program
  • Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint
  • Able to digitally sign a PDF file without adobe reader installed
  • Add a signature or an empty signature field in any PDF file page
  • Ability to insert signature in PDF form
  • Detect and search signature field in PDF document
  • Insert PDF signature certificate to sign PDF file
  • Verify the validity of PDF signature
  • Remove signature from PDF document




C# add digital signature to PDF document


        #region add digital signature to PDF document
        internal static void addDigitalSignature()
        {
            String inputFilePath = @"...";
            String outputFilePath = @"...";
            String imagePath = @"...";
            String certSubjectName = @"...";
            String fieldID = @"...";

            X509Cert cert = PDFDigitalSignatureHandler.MakeCert(StoreName.My, StoreLocation.CurrentUser, certSubjectName);

            // Set cert properties.
            cert.Location = "CHINA SHANGHAI";
            cert.Reason = "Reason";
            cert.APMode = APMode.Text; // APMode.Text | APMode.Image.
            cert.Image = new Bitmap(imagePath);

            if (PDFDigitalSignatureHandler.Sign(inputFilePath, outputFilePath, cert, fieldID) == 0)
            {
                Console.WriteLine("[SUCCESS]");
            }
            else
            {
                Console.WriteLine("[FAILED]");
            }
        }
        #endregion




C# search unsigned signature field in the PDF document


String inputFilePath = @"...";
List<SignatureField> vals = PDFDigitalSignatureHandler.SearchUnsignedFields(inputFilePath);
if (vals == null || vals.Count == 0)
{
    Console.WriteLine("No Signature Field");
}
else
{
    Console.WriteLine("Signature Fields");

    for (int i = 0; i < vals.Count; i++)
    {
        Console.WriteLine(i + ": " + vals[i].ID + " (Pg " + vals[i].PageIndex + ")");
    }
}




C# prepare a certification which used to sign a document


StoreName storeName = StoreName.My;
StoreLocation storeLocation = StoreLocation.CurrentUser;
String subjectName = "";

List<String> allSubjects = PDFDigitalSignatureHandler.GetAllSubjectNames(storeName, storeLocation, true);
foreach (String str in allSubjects)
{
    Console.WriteLine("Make certification by name: " + str);
    X509Cert cert = PDFDigitalSignatureHandler.MakeCert(storeName, storeLocation, str);

//	
}




C# add an empty signature field to pdf document


String inputFilePath = @"...";
String outputFilePath = @"...";

PDFSignature signature = new PDFSignature(new RectangleF(10F, 10F, 250F, 150F));
if (PDFDigitalSignatureHandler.CreateSignatureField(inputFilePath, outputFilePath, signature, 0) == 0)
{
    Console.WriteLine("[SUCCESS]");
}
else
{
    Console.WriteLine("[FAILED]");
}




C# sign a PDF document


String inputFilePath = @"...";
String outputFilePath = @"...";
String imagePath = @"...";
String certSubjectName = @"...";
String fieldID = @"...";

X509Cert cert = PDFDigitalSignatureHandler.MakeCert(StoreName.My, StoreLocation.CurrentUser, certSubjectName);
//  set cert properties
cert.Location = "CHINA SHANGHAI";
cert.Reason = "Reason";
cert.APMode = APMode.Text;      //  APMode.Text | APMode.Image
cert.Image = new Bitmap(imagePath);

if (PDFDigitalSignatureHandler.Sign(inputFilePath, outputFilePath, cert, fieldID) == 0)
{
    Console.WriteLine("[SUCCESS]");
}
else
{
    Console.WriteLine("[FAILED]");
}








Common Asked Questions

How do you put a digital signature on a PDF?

Open a PDF file using Acrobat. Navigate to the page where you want to add a digital signature. Click "Tools" from toolbar. Click "Fill & Sign" from "Forms & Signatures" group. Using RasterEdge XDoc.PDF C# library, you can quickly add digital signature to PDF file using method "PDFDigitalSignatureHandler.MakeCert()" in your ASP.NET Core, Windows Forms, and WPF applications.

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

You can use free online tools or desktop programs to add a signature to a PDF document without any cost. You can build a simple online web app with digital signature enabled using C# PDF library.

Does a PDF have a digital signature?

You can add digital signature to a PDF using free online tools or paid desktop applications such as Adobe Acrobat. Using RasterEdge C# PDF library, you can freely add a digital signature to any place in the PDF document in your ASP.NET, Windows projects.

Can I copy and paste a signature to a PDF?

Yes. You can copy and paste a digital signature to a PDF using PDF editing software. Using RasterEdge C# PDF SDK api, you can read an existing digital signature and clone one on the PDF document in your ASP.NET, MVC Windows applications.

How do I create a handwritten signature for a PDF?

You can draw your handwritten signature using an image editor software, and save to an image file. Then you can use any PDF editing software (online or desktop) to add the image with hand writing signature to the PDF document. Using C# PDF component, you can quickly add the image signature to the specified place in the PDF document using C# codes.

How do I add a digital signature stamp to a PDF?

Using C# PDF library security API, you can easily add a signature with stamp image using method "PDFDigitalSignatureHandler.MakeCert()".

How do I add a digital signature to a PDF without Acrobat?

A lot of online free PDF tools support adding digital signature to PDF document without Acrobat installed. You even develop and build such free web tool to manage (add, remove, edit) digital signature using RasterEdge C# .NET PDF SDK library.