Hi
Your TextFind example works with PdfTextFinder but I can't find PdfTextFinder in the API reference.
In the API reference I find PdfTextExtractor instead.
what is the difference
Regards Peter
https://www.e-iceblue.com/Tutorials/Spire.PDF/Spire.PDF-Program-Guide/Text/Find-and-Highlight-Selected-Text-in-PDF-in-C-VB.NET.html
String input = @"..\..\..\..\..\..\Data\SearchReplaceTemplate.pdf";
PdfDocument doc = new PdfDocument();
// Read a pdf file
doc.LoadFromFile(input);
// Get the first page of pdf file
PdfPageBase page = doc.Pages[0];
// Create a PdfTextFinder object for searching text within the page
PdfTextFinder finder = new PdfTextFinder(page);
finder.Options.Parameter = Spire.Pdf.Texts.TextFindParameter.IgnoreCase;
// Find occurrences of the specified text within the page
List<PdfTextFragment> finds = finder.Find("Spire.PDF for .NET");
String newText = "E-iceblue Spire.PDF";
// Creates a brush
PdfBrush brush = new PdfSolidBrush(Color.DarkBlue);
// Defines a font
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 12f, FontStyle.Regular));
RectangleF rec;
// Iterate through each found text fragment
foreach (PdfTextFragment find in finds)
{
// Gets the bound of the found text in page
rec = find.Bounds[0];
page.Canvas.DrawRectangle(PdfBrushes.White, rec);
// Draws new text as defined font and color
page.Canvas.DrawString(newText, font, brush, rec);
// This method can directly replace old text with newText,but it just can set the background color, can not set font/forecolor
// find.ApplyRecoverString(newText, Color.Gray);
}
String result = "ReplaceAllSearchedText_out.pdf";
//Save the document
doc.SaveToFile(result);
https://www.e-iceblue.com/Tutorials/Spire.PDF/Spire.PDF-Program-Guide/How-to-Extract-Text-from-PDF-Document-with-C-/VB.NET.html