VintaSoft Imaging .NET SDK v8.7
Vintasoft.Imaging.Pdf.Tree.InteractiveForms Namespace / PdfInteractiveFormField Class / Remove Method
Example



In This Topic
    Remove Method (PdfInteractiveFormField)
    In This Topic
    Deletes the field and all children from interactive form tree, also removes all widget annotations of deleted subtree from annotations of PDF pages.
    Syntax
    'Declaration
     
    Public Function Remove() As Boolean
    public bool Remove()
    public: bool Remove(); 
    public:
    bool Remove(); 
    Example
    This example shows how to remove a signature from PDF document.
    ''' <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 Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename)
    		' if PDF document has PDF interactive form
    		If document.InteractiveForm IsNot Nothing Then
    			' get reference to the interactive form of PDF document
    			Dim form As Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfDocumentInteractiveForm = document.InteractiveForm
                
    			' get all signature fields of PDF document
    			Dim signatureFields As Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormSignatureField() = form.GetSignatureFields()
                
    			' for each signature fields
    			For Each field As Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormField In signatureFields
    				' remove signature field
    				field.Remove()
    			Next
                
    			' pack PDF document
    			document.Pack()
    		End If
    	End Using
    End Sub
    /// <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 (Vintasoft.Imaging.Pdf.PdfDocument document = 
            new Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename))
        {
            // if PDF document has PDF interactive form
            if (document.InteractiveForm != null)
            {
                // get reference to the interactive form of PDF document
                Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfDocumentInteractiveForm form = 
                    document.InteractiveForm;
                
                // get all signature fields of PDF document
                Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormSignatureField[] signatureFields = 
                    form.GetSignatureFields();
                
                // for each signature fields
                foreach (Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormField field in signatureFields)
                {
                    // remove signature field
                    field.Remove();
                }
                
                // pack PDF document
                document.Pack();
            }
        }
    }
    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also