Articles in this section
Category / Section

How to Get Number of Digital Signatures Loaded in ASP.NET Core PDF?

3 mins read

The Syncfusion Essential PDF is a feature-rich and high-performance ASP.NET Core PDF used to create, read, and edit PDF documents programmatically without Adobe dependencies. With this library, you can use C# to determine the number of digital signatures present in a loaded PDF document.

Steps to get the number of digital signatures in a loaded PDF Programmatically:

  1. Create a new console application project.

ConsoleApp.png

  1. Install the Syncfusion.Pdf.Net.Core NuGet package as a reference to your console application from Nuget.org.

NuGetPackage.png

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

C#

using Syncfusion.Pdf.Parsing;
  1. Use the following code sample in Program.cs to get the number of digital signatures in the PDF file.

C#

// Initialize a counter to count the number of signature fields in the PDF document
int signedFieldsCount = 0; 
int unSignedFieldsCount = 0;

// Open the PDF document as a file stream
using (FileStream docStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read))
{
   // Load the PDF document from the file stream
   using (PdfLoadedDocument doc = new PdfLoadedDocument(docStream))
   {
       // Access the form inside the loaded PDF document
       PdfLoadedForm form = doc.Form;        

       // Iterate through each field in the form field collection
       foreach (PdfLoadedField field in form.Fields)
       {
           PdfLoadedSignatureField sigField = field as PdfLoadedSignatureField;
           // Check whether the signature field is signed or not
           if (sigField != null)
           {
               if (sigField.IsSigned)
               {
                   signedFieldsCount++;
               }
               else
               {
                   unSignedFieldsCount++;
               }
           }
       }

       // Display the total number of signature fields found in the PDF document
       Console.WriteLine("The number of signed signature fields in the PDF document: " + signedFieldsCount);
       Console.WriteLine("The number of unSigned signature fields in the PDF document: " + unSignedFieldsCount);
   }
}

A complete working sample can be downloaded from GitHub.

Take a moment to peruse the documentation for working on digital signature where you will find various options for loading and signing an existing document.

Conclusion
I hope you enjoyed learning about how to get number of digital signatures loaded in ASP.NET Core PDF.

You can refer to our ASP.NET Core PDF feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our ASP.NET Core PDF example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to 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 our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

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