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 Mar 25, 2020 3:47 am

Hello,

I have an article, and I want highlight the paragraph which in different page.

I already referenced "Find and Highlight Text in PDF in Java" in website, like this:
Code: Select all
public class SpirePdfHighlight {
    public static void main(String[] args) throws Exception {
        // Load the document from disk
        PdfDocument pdf = new PdfDocument();
        pdf.loadFromFile("C:\\Users\\Desktop\\10.pdf");

        pdf.getPages().add();

        PdfTextFind[] result = null;
        for (Object pageObj : pdf.getPages()) {
            PdfPageBase page = (PdfPageBase) pageObj;
            // Find text
            result = page.findText("You can’t get hold of a mask at all", false).getFinds();
            for (PdfTextFind find : result) {
                // Highlight searched text
                find.applyHighLight();
            }
        }

        String output = "C:\\Users\\Desktop\\TEST\\Spire.pdf";
        // Save the document
        pdf.saveToFile(output, FileFormat.PDF);
    }
}

But obviously, it can highlight only in the same page.

So I would like to ask for help... is there any way to highlight the paragraph which in different page?

THX!!

NewCustomer0323
 
Posts: 2
Joined: Mon Mar 23, 2020 9:17 am

Wed Mar 25, 2020 7:08 am

Hello,

Thanks for your inquiry.
You mean that if the content of the text is on two different pages, just like the attached screenshot, it cannot be highlighted, right? Kindly note the method "page.findText" you used can just find the text on a single page. Thus, if the text spans two pages, this method will return null. So it cannot be highlighted.
Meanwhile, I found that even using the find function in Adobe, it can't also find text that spans two pages. Sorry, our Spire.PDF can't either. Hope you can understand.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Wed Mar 25, 2020 8:37 am

Thanks for your reply.

Yes, my problem is ike the screenshot you attached.
And thanks for your detailed explanation, I got it now.

Many thanks.

NewCustomer0323
 
Posts: 2
Joined: Mon Mar 23, 2020 9:17 am

Wed Mar 25, 2020 8:56 am

Hello,

Thanks for your prompt response.
If there is anything else we can do for you, just feel free to contact us.
Wish you all the best!

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Wed Aug 25, 2021 9:18 am

Hello,
Is there anything we can do with Pro Edition ? For paragraph in two different pages.


Sincerely,
Ankit

ankitsahay
 
Posts: 1
Joined: Wed Aug 25, 2021 9:12 am

Wed Aug 25, 2021 10:13 am

Hi Ankit,

Thanks for your inquiry.

I'm sorry that even with the Pro version, we can only find text in a single page. Apologize for the inconvenience caused.

If you have any other questions, please feel free to contact us.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.PDF