//// This code is part of Document Solutions for PDF .NET demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem.IO;usingGrapeCity.Documents.Pdf;usingGrapeCity.Documents.Pdf.AcroForms; namespaceDsPdfWeb.Demos{// This sample shows how to find and remove existing signatures// from a PDF that had been digitally signed. // See the RemoveSignatureFields for code that removes any// signature fields instead. // The PDF used in this sample was created by TimeSheet.publicclassRemoveSignatures {publicintCreatePDF(Stream stream) {var doc = newGcPdfDocument();using (var fs = File.OpenRead(Path.Combine("Resources", "PDFs", "TimeSheet.pdf"))) { doc.Load(fs); // Fields can be children of other fields, so we use// a recursive method to iterate through the whole tree:removeSignatures(doc.AcroForm.Fields); // Done: doc.Save(stream);return doc.Pages.Count; voidremoveSignatures(FieldCollection fields) {foreach (var f in fields) {if (f isSignatureField sf) sf.Value = null;removeSignatures(f.Children); } } } } }}