Hi there,
i am using FreeSpire.Pdf in my Visual Studio 2019.i want to find and highlight the text in my pdf. i try the below code but it's not working.can any one help me?
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile("xxxxx\myfile.pdf");
PdfTextFind[] result = null;
PdfBrush brush = new PdfSolidBrush(Color.DarkBlue);
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 12f, FontStyle.Regular));
RectangleF rec;
foreach (PdfPageBase page in pdf.Pages)
{
result = page.FindText("Attn").Finds;
foreach (PdfTextFind find in result)
{
rec = find.Bounds;
page.Canvas.DrawRectangle(PdfBrushes.White, rec);
// find.ApplyHighLight();
}
}
pdf.SaveToFile("xxxxx\result.pdf", FileFormat.PDF);