Some test text!


Search for text in a PDF

Only available with the Full API

To search for text in a PDF using regular expression.

const doc = await PDFNet.PDFDoc.createFromURL(filename);
const txtSearch = await PDFNet.TextSearch.create();
let mode = PDFNet.TextSearch.Mode.e_whole_word + PDFNet.TextSearch.Mode.e_page_stop; // Uses both whole word and page stop
let pattern = '';

//use regular expression to find credit card number
mode += PDFNet.TextSearch.Mode.e_reg_expression + PDFNet.TextSearch.Mode.e_highlight;
pattern = '\\d{4}-\\d{4}-\\d{4}-\\d{4}'; // or "(\\d{4}-){3}\\d{4}"

//call Begin() method to initialize the text search.
txtSearch.begin(doc, pattern, mode);
const result = await;

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.

PDFTron Receives USD$71 Million Growth Investment Led By Silversmith Capital Partners

Learn more