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.

Wed Oct 06, 2021 9:58 pm

Attempting to highlight text in an existing pdf in a C# .net core application.

Adding the latest version of the spire.pdf dlls did not have an effect.

Some of the time, when I find text to highlight and call find.ApplyHighLight(), it highlights exactly where I would expect, that is around the found text. Other times, it highlights what looks to be half a line above the found text. The following two examples come from the same document:
off-highlight.png


This one hits the target.
on-highlight.png


I tried drawing rectangles around the found text and got the same kind of results.

This is my code
Code: Select all
            var found = page.FindText(pattern, Spire.Pdf.General.Find.TextFindParameter.Regex);
            if (found?.Finds?.Length > 0)
            {
                foreach (PdfTextFind find in found.Finds)
                {
                    // DrawRect(page, find);
                    find.ApplyHighLight();
                }
            }


It looks like, in the first case, there is some kind of padding in the paragraph formatting of the area the text was found in such that I need to go a few pixels lower.

Is there anyway I can programmatically find this offset?

cedar.bristol
 
Posts: 1
Joined: Wed Oct 06, 2021 9:07 pm

Thu Oct 07, 2021 1:48 am

Hello,

Thanks for your inquiry!

I simulated a PDF file and did an initial test in .NET Core 2.0 application, but did not reproduce your issue.

To help further look into your issue, please share us with your input file, the target framework(e.g. .NET Core 2.0), your system information (E.g. Win10, 64 bit) and region setting (E.g. China, Chinese) . Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon Nov 22, 2021 9:40 am

Hello,

Greetings from E-iceblue.

How is the issue you posted on our forum now? If it still exists, could you please provide your input file, the target framework(e.g. .NET Core 2.0), your system information (E.g. Win10, 64 bit) and region setting (E.g. China, Chinese)to us for further investigation?

Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Return to Spire.PDF