Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Aug 29, 2022 6:20 am

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);

VivekMurugesh
 
Posts: 1
Joined: Mon Aug 29, 2022 6:10 am

Mon Aug 29, 2022 10:02 am

Hi,

Thanks for your inquiry.
I did an initial test, but did not reproduce your problem. Please note that Spire.PDF provides the ApplyHighLight() method to set the highlight for the text without drawing a rectangle. I suggest that you give the latest commercial version(Spire.PDF Pack(Hot Fix) Version:8.8.6) a try as it contains more fixes and new features than the free version and is more stable. If the issue still occurs after trying, please provide the following information for further investigation. You can attach your file here or send it to us via email ([email protected]).
1) Your input document.
2) Test environment, such as win10, 64bit.
3) Application type, such as Console App, .NET Framework 4.8.

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Mon Oct 31, 2022 7:19 am

Hi,

Greetings from E-iceblue.
How is your issue going? Could you please give us some feedback at your convenience? Thanks in advance.

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Return to Spire.PDF