'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DrawingImportsSystem.Text.RegularExpressionsImportsGrapeCity.Documents.PdfImportsGrapeCity.Documents.Pdf.AnnotationsImportsGrapeCity.Documents.Pdf.AcroForms '' This sample shows how to use the text map to find specific content '' in a PDF And mark it for redaction.'' The PDF used in this sample was created by TimeSheet.PublicClassFindAndRedactPublicFunctionCreatePDF(ByVal stream AsStream) AsIntegerDim doc = NewGcPdfDocument()Using fs AsNewFileStream(Path.Combine("Resources", "PDFs", "TimeSheet.pdf"), FileMode.Open, FileAccess.Read) doc.Load(fs) '' Note: Acrobat does not allow applying redactions in a digitally signed'' document, so first we find and remove any existing signatures:RemoveSignatureFields(doc.AcroForm.Fields) '' Loop through pages, removing anything that looks Like a short dateForEach page In doc.PagesDim tmap = page.GetTextMap()ForEach tline In tmapIf (Regex.Match(tline.Text.Trim(), "\d+[/-]\w+[/-]\d").Success) ThenDim redact = NewRedactAnnotation() With { .Rect = tline.GetCoords().ToRect(), .Color = Color.Red, .Page = page, .MarkBorderColor = Color.Red, .MarkFillColor = Color.Yellow }'' If we hadn't already set redact.Page = page, we could do this:'' page.Annotations.Add(redact)EndIfNextNext'' Done doc.Save(stream)Return doc.Pages.CountEndUsingEndFunction '' This code Is from the RemoveSignatureFields sample:SubRemoveSignatureFields(ByVal fields AsFieldCollection)For i = fields.Count - 1To0Step -1RemoveSignatureFields(fields(i).Children)IfTypeOf fields(i) IsSignatureFieldThen fields.RemoveAt(i)EndIfNextEndSubEndClass