How can I help you?
Use extractTextCompleted to extract text in TypeScript PDF Viewer
16 Feb 20261 minute to read
Use the isExtractText property together with the extractTextCompleted event to extract page text and its positional bounds from a loaded PDF document.
The following example shows how to enable text extraction and handle the completion event:
viewer.isExtractText = true;
viewer.extractTextCompleted = args => {
//Extract the Complete text of load document
console.log(args);
console.log(args.documentTextCollection[1]);
//Extract the Text data.
console.log(args.documentTextCollection[1][1].textData);
//Extract Text in the Page.
console.log(args.documentTextCollection[1][1].pageText);
//Extracts the first text of the PDF document along with its bounds
console.log(args.documentTextCollection[1][1].textData[0].Bounds);
};Find the sample: How to extract text