Some test text!


Text search (Android)

There are two parts to text searching. First is the UI component that is presented to the user. Second is an API guide to perform the text search functionality.

Text search API for Android

To search for text in a PDF using regular expression.

PDFDoc doc = new PDFDoc(filename);
Int32 page_num = 0;
String result_str = "", ambient_string = "";
Highlights hlts = new Highlights();
TextSearch txt_search = new TextSearch();
Int32 mode = (Int32)(TextSearch.SearchMode.e_whole_word | TextSearch.SearchMode.e_page_stop | TextSearch.SearchMode.e_highlight);
String pattern = "";

//use regular expression to find credit card number
mode |= (Int32)(TextSearch.SearchMode.e_reg_expression | TextSearch.SearchMode.e_highlight);
String pattern = "\\d{4}-\\d{4}-\\d{4}-\\d{4}"; //or "(\\d{4}-){3}\\d{4}"

//call Begin() method to initialize the text search.
txt_search.Begin( doc, pattern, mode, -1, -1 );
TextSearch.ResultCode code = txt_search.Run(ref page_num, ref result_str, ref ambient_string, hlts );

Search PDF files for text
Full code sample which shows how to use TextSearch to search text on PDF pages using regular expressions.

Get the answers you need: Support


Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.