How to Find Text in a PDF File
Learn More on JPedal Text Search
The link below provide links to Javadocs including sample source code for finding text in a PDF.
- FindTextInRectangle – View Javadoc for API to search PDF files for text.
A note on co-ordinates
Examples use the PDF co-ordinates which start at bottom left of page and run up the page. This is the opposite of Java (which run from top left down page).
For complex searches, you can set a SearchType. Valid values are
- public final static int DEFAULT = 0;
- public final static int WHOLE_WORDS_ONLY = 1;
- public final static int CASE_SENSITIVE = 2;
- public final static int FIND_FIRST_OCCURANCE_ONLY = 4;
- public final static int MUTLI_LINE_RESULTS = 8;
- public final static int HIGHLIGHT_ALL_RESULTS = 16;
- public final static int USE_REGULAR_EXPRESSIONS= 32;
These values can be combined by using the bitwise or operator. For example,
int searchType = SearchType.WHOLE_WORDS_ONLY | SearchType.CASE_SENSITIVE;