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.

Thu Mar 14, 2019 1:20 pm

Hello,

I'm trying to use the function FindText with the option ignoreCase true:

finds = pPage.FindText("Some Text", true, true).Finds;

but looks like it doesn't work.
How can i do to search some text in a pdf file ignoring case sensitive?
Thank you.

Luke

Luke_77
 
Posts: 4
Joined: Thu Jan 31, 2019 3:10 pm

Fri Mar 15, 2019 2:15 am

Hello,

Thanks for your inquiry.
Please use the following setting to search text in a pdf file and ignore case sensitive. If there is any other question, welcome to write back.
Code: Select all
finds = pPage.FindText("Some Text", false, true).Finds;

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Tue Mar 19, 2019 9:59 am

Hello,

Greetings from E-iceblue.
Did the code work for you? Your feedback will be greatly appreciated.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Fri Jul 15, 2022 12:36 pm

When I search for the word "sex" in a document it takes words like "is excluded" and highlights the "s" and the "ex". This happens when I use page.FindText(word, false, true).Finds.

If I use page.FindText(word, true, true).Finds then search whole word seems to work BUT it does NOT ignore case. How can I get search whole word AND ignore case to work?

davidross
 
Posts: 1
Joined: Fri Jul 15, 2022 12:27 pm

Mon Jul 18, 2022 9:39 am

Hello David Noe,

Thanks for your message.
I did an initial test with our latest Spire.PDF Pack(Hot Fix) Version:8.7.2, but I didn't reproduce your issue. If you were using an old version, I suggest that you upgrade to the latest one to try again. Besides, the method has some adjustments in our latest version, please use the following sample code to test.
If there is still any question, please share us with your input PDF file for further testing.
Code: Select all
            PdfDocument pdf = new PdfDocument();
            pdf.LoadFromFile(@"input.pdf");
            PdfTextFind[] result = null;
            foreach (PdfPageBase page in pdf.Pages)
            {
            //old method
            //result = page.FindText("sex", true, true).Finds;
            result = page.FindText("sex",TextFindParameter.IgnoreCase| TextFindParameter.WholeWord).Finds;
            foreach (PdfTextFind find in result)
            {
            find.HighLight();
            }
            }
            string output = @"out.pdf";
            pdf.SaveToFile(output, FileFormat.PDF);

Sincerely,
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Thu Jul 21, 2022 1:37 am

Hello David Noe,

Could you please let us know how is your issue going? Thanks in advance for your feedback and time.

Sincerely,
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Return to Spire.PDF

cron