PDF: How to remove digital signature from PDF document
In This Topic
If digital gignature should be removed from PDF document, the following steps must be done:
- Find the field that stores the digital signature
- Remove the field from interactive form of PDF document
- Save the PDF document
Here is C#/VB.NET code that demonstrates how to remove all digital signatures from PDF document:
using Vintasoft.Imaging.Pdf;
using Vintasoft.Imaging.Pdf.Tree.InteractiveForms;
public class PdfSignaturesHelper2
{
/// <summary>
/// Removes all digital signatures from PDF document.
/// </summary>
/// <param name="pdfFilename">The filename of PDF document.</param>
public static void RemoveDigitalSignaturesFromPdfDocument(string pdfFilename)
{
// open PDF document
using (PdfDocument document = new PdfDocument(pdfFilename))
{
// if PDF document has PDF interactive form
if (document.InteractiveForm != null)
{
// for each signature field
foreach (PdfInteractiveFormField field in
document.InteractiveForm.GetSignatureFields())
{
// remove signature field
field.Remove();
}
// pack PDF document
document.Pack();
}
}
}
}
Imports Vintasoft.Imaging.Pdf
Imports Vintasoft.Imaging.Pdf.Tree.InteractiveForms
Public Class PdfSignaturesHelper2
''' <summary>
''' Removes all digital signatures from PDF document.
''' </summary>
''' <param name="pdfFilename">The filename of PDF document.</param>
Public Shared Sub RemoveDigitalSignaturesFromPdfDocument(pdfFilename As String)
' open PDF document
Using document As New PdfDocument(pdfFilename)
' if PDF document has PDF interactive form
If document.InteractiveForm IsNot Nothing Then
' for each signature field
For Each field As PdfInteractiveFormField In document.InteractiveForm.GetSignatureFields()
' remove signature field
field.Remove()
Next
' pack PDF document
document.Pack()
End If
End Using
End Sub
End Class
Please read how to add digital signature to a PDF document
here.
Please read how to verify the digital signatures in PDF document
here.