Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save conholdate-gists/d898aef6421ae113236f9da6c4078ebe to your computer and use it in GitHub Desktop.
Save conholdate-gists/d898aef6421ae113236f9da6c4078ebe to your computer and use it in GitHub Desktop.
Remove Digital Signatures from Documents & Images in C# .NET
// Supported file formats: https://docs.groupdocs.com/signature/net/supported-document-formats/
using (Signature signature = new Signature("signed.pdf"))
{
BarcodeSearchOptions options = new BarcodeSearchOptions();
// search for Barcode signatures in document
List<BarcodeSignature> signatures = signature.Search<BarcodeSignature>(options);
if (signatures.Count > 0)
{
BarcodeSignature barcodeSignature = signatures[0];
bool result = signature.Delete(barcodeSignature);
if (result)
{
Console.WriteLine($"Signature with Barcode '{barcodeSignature.Text}' and encode type '{barcodeSignature.EncodeType.TypeName}' was deleted from document ['{fileName}'].");
}
else
{
Console.WriteLine($"Signature was not deleted from the document! Signature with Barcode '{barcodeSignature.Text}' and encode type '{barcodeSignature.EncodeType.TypeName}' was not found!");
}
}
}

Remove Digital Signatures from Documents & Images in C# .NET

The below C# .NET code examples demonstrates how to remove electronic signatures types (barcode, text, image, qr-code) from digital documents and images without requiring any third party applications or Microsoft Office installed on the devices.

View a list of all supported document formats by Conholdate.Total for .NET.

APIs to Use

Installation

Download Conholdate.Total APIs from https://downloads.conholdate.com/total/net or install the whole package directly from NuGet https://www.nuget.org/packages/Conholdate.Total/ into your workplace.

More About .NET Documents Signature API

Home | Product Page | Docs | New Releases | API Reference | Examples | Blog | Free Support | Temporary License | About Us

// Supported file formats: https://docs.groupdocs.com/signature/net/supported-document-formats/
using (Signature signature = new Signature("signed.pdf"))
{
// search for electronic Digital signatures in the document
List<DigitalSignature> signatures = signature.Search<DigitalSignature>(SignatureType.Digital);
if (signatures.Count > 0)
{
DigitalSignature digitalSignature = signatures[0];
bool result = signature.Delete(digitalSignature);
if (result)
{
Console.WriteLine($"Digital signature #{digitalSignature.Thumbprint} from the {digitalSignature.SignTime.ToShortDateString()} was deleted.");
}
else
{
Helper.WriteError($"Signature was not deleted from the document! Signature# {digitalSignature.Thumbprint} was not found!");
}
}
}
// Supported file formats: https://docs.groupdocs.com/signature/net/supported-document-formats/
using (Signature signature = new Signature("signed.pdf"))
{
TextSearchOptions options = new TextSearchOptions();
// search for text signatures in document
List<TextSignature> signatures = signature.Search<TextSignature>(options);
if(signatures.Count > 0)
{
TextSignature textSignature = signatures[0];
bool result = signature.Delete(textSignature);
if(result)
{
Console.WriteLine($"Signature with Text '{textSignature.Text}' was deleted from document.");
}
else
{
Console.WriteLine($"Signature was not deleted from the document!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment