Obtain document form fields and signatures information

GroupDocs.Signature allows to get extended document information which includes:

Analyze document form fields and signatures information

The following code snippet demonstrates how to obtain information about document form fields, signatures and analyze them.

using (Signature signature = new Signature("sampleSigned.pdf"))
{
    IDocumentInfo documentInfo = signature.GetDocumentInfo();
    Console.WriteLine($"Document properties {Path.GetFileName(filePath)}:");
    Console.WriteLine($" - format : {documentInfo.FileType.FileFormat}");
    Console.WriteLine($" - extension : {documentInfo.FileType.Extension}");
    Console.WriteLine($" - size : {documentInfo.Size}");
    Console.WriteLine($" - page count : {documentInfo.PageCount}");
    foreach (PageInfo pageInfo in documentInfo.Pages)
    {
        Console.WriteLine($" - page-{pageInfo.PageNumber} Width {pageInfo.Width}, Height {pageInfo.Height}");
    }
    // display document Form Field signatures information
    Console.WriteLine($"Document Form Fields information: count = {documentInfo.FormFields.Count}");
    foreach (FormFieldSignature formField in documentInfo.FormFields)
    {
        Console.WriteLine($" - type #{formField.Type}: Name: {formField.Name} Value: {formField.Value}");
    }
    // display document Text signatures information
    Console.WriteLine($"Document Text signatures : {documentInfo.TextSignatures.Count}");
    foreach (TextSignature textSignature in documentInfo.TextSignatures)
    {
        Console.WriteLine($" - #{textSignature.SignatureId}: Text: {textSignature.Text}");
    }
    // display document Image signatures information
    Console.WriteLine($"Document Image signatures : {documentInfo.ImageSignatures.Count}");
    foreach (ImageSignature imageSignature in documentInfo.ImageSignatures)
    {
        Console.WriteLine($" - #{imageSignature.SignatureId}: Size: {imageSignature.Size} bytes, Format: {imageSignature.Format}.");
    }
    // display document Digital signatures information
    Console.WriteLine($"Document Digital signatures : {documentInfo.DigitalSignatures.Count}");
    foreach (DigitalSignature digitalSignature in documentInfo.DigitalSignatures)
    {
        Console.WriteLine($" - #{digitalSignature.SignatureId}.");
    }
    // display document Barcode signatures information
    Console.WriteLine($"Document Barcode signatures : {documentInfo.BarcodeSignatures.Count}");
    foreach (BarcodeSignature barcodeSignature in documentInfo.BarcodeSignatures)
    {
        Console.WriteLine($" - #{barcodeSignature.SignatureId}: Type: {barcodeSignature.EncodeType?.TypeName}. Text: {barcodeSignature.Text}");
    }
    // display document QrCode signatures information
    Console.WriteLine($"Document QR-Code signatures : {documentInfo.QrCodeSignatures.Count}");
    foreach (QrCodeSignature qrCodeSignature in documentInfo.QrCodeSignatures)
    {
        Console.WriteLine($" - #{qrCodeSignature.SignatureId}: Type: {qrCodeSignature.EncodeType?.TypeName}. Text: {qrCodeSignature.Text}");
    }
    // display document Form Fields signatures information
    Console.WriteLine($"Document Form Fields signatures : {documentInfo.FormFieldSignatures.Count}");
    foreach (FormFieldSignature formFieldSignature in documentInfo.FormFields)
    {
        Console.WriteLine($" - #{formFieldSignature.SignatureId} Type {formFieldSignature.Type}: Name: {formFieldSignature.Name} Value: {formFieldSignature.Value}");
    }
    // display document Metadata signatures information
    Console.WriteLine($"Document Metadata signatures : {documentInfo.MetadataSignatures.Count}");
    foreach (MetadataSignature metadataSignature in documentInfo.MetadataSignatures)
    {
        Console.WriteLine($" - #{metadataSignature.Name} = {metadataSignature.Value}.Type:{metadataSignature.Type}");
    }
}

More resources

GitHub Examples

You may easily run the code above and see the feature in action in ourΒ GitHub examples:

Free Online Apps

Along with the full-featured .NET library, we provide simple but powerful free online apps.

To sign PDF, Word, Excel, PowerPoint, and other documents you can use the online apps from the GroupDocs.Signature App Product Family.