Hi Team,
Exception message logged is "Object reference not set to an instance of an object."
Hi Navaneethan,
Hi Team,
Hi Navaneethan,
Hi Navaneethan,
Aspose.Pdf.Document
doc = new Aspose.Pdf.Document(myDir+“testContent.pdf”);<o:p></o:p>
//
foreach (string keyword in keywords)<o:p></o:p>
{<o:p></o:p>
TextFragmentCollection textFragmentCollection =
SearchPDF(doc, “Accenture”);<o:p></o:p>
//loop through the fragments<o:p></o:p>
foreach (TextFragment
textFragment in textFragmentCollection)<o:p></o:p>
{<o:p></o:p>
// create
RedactionAnnotation instance for specific page region<o:p></o:p>
Aspose.Pdf.Annotations.RedactionAnnotation
annot = new Aspose.Pdf.Annotations.RedactionAnnotation(doc.Pages[textFragment.Page.Number],
textFragment.Rectangle);<o:p></o:p>
annot.FillColor = Aspose.Pdf.Color.Black;<o:p></o:p>
annot.BorderColor = Aspose.Pdf.Color.Yellow;<o:p></o:p>
annot.Color = Aspose.Pdf.Color.Blue;<o:p></o:p>
// text to be printed on redact annotation<o:p></o:p>
// annot.OverlayText = “REDACTED”;<o:p></o:p>
annot.TextAlignment = Aspose.Pdf.HorizontalAlignment.Center;<o:p></o:p>
// repat Overlay text over redact Annotation<o:p></o:p>
annot.Repeat = true;<o:p></o:p>
// add annotation to annotations collection of first page<o:p></o:p>
doc.Pages[textFragment.Page.Number].Annotations.Add(annot);<o:p></o:p>
// Flattens annotation and redacts page contents (i.e.
removes text and image<o:p></o:p>
// under redacted annotation)<o:p></o:p>
annot.Redact();<o:p></o:p>
<o:p></o:p>
}<o:p></o:p>
}<o:p></o:p>
doc.Save(myDir+"AnnotationOutput.pdf");
Please feel free to contact us for any further assistance.
Best Regards,
The issues you have found earlier (filed as PDFNET-40512) have been fixed in Aspose.PDF for .NET 23.4.