Skip to content
Advertisement

How to search for a string in a pdf document [closed]

I have a pdf document which contains images, hyperlinks , words and many other things.

I want to search for a sting in all the words, i.e images and hyperlinks are excluded. How to write a java code with that. Could someone help here.

Advertisement

Answer

You can use the PDFbox library of Apache (https://pdfbox.apache.org/download.cgi). Here is an example of code.

JavaScript

Remember you will have to download PDFbox jar file and import it into your project.

Output/Result :

enter image description here

Edit:

You can also find the number of phrases in the PDF :

JavaScript

Output/Result : enter image description here

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement