Remove a Signature Field from a PDF in C#
To remove a signature field, use the RemoveSignature
method. It requires only the signature index as its parameter. Use the GetSignatureCount
method to get the total number of signatures.
If you have only one signature in a PDF document, you can skip the
GetSignatureCount
method and use theRemoveSignature
method with the signature index set to0
as its parameter.
To delete all signature fields, use the following code:
using GdPicturePDF gdPicturePDF = new GdPicturePDF(); gdPicturePDF.LoadFromFile(@"C:\temp\source.pdf"); // Get the total amount of signatures. int signatureCount = gdPicturePDF.GetSignatureCount(); for (int i = 0; i <= signatureCount - 1; i++) { // Remove the signature. gdPicturePDF.RemoveSignature(0); } gdPicturePDF.SaveToFile(@"C:\temp\output.pdf");
Using gdPicturePDF As GdPicturePDF = New GdPicturePDF() gdPicturePDF.LoadFromFile("C:\temp\source.pdf") ' Get the total amount of signatures. Dim signatureCount As Integer = gdPicturePDF.GetSignatureCount() For i = 0 To signatureCount - 1 ' Remove the signature. gdPicturePDF.RemoveSignature(0) Next gdPicturePDF.SaveToFile("C:\temp\output.pdf") End Using