Pdf Data Extract - PdfDataExtractor

30 Sep 20265 minutes to read

Represents a utility for extracting data from a PDF document.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Initialize a new instance of the `PdfDataExtractor` class
let extractor: PdfDataExtractor = new PdfDataExtractor(document);
// Extract `TextLine` from the PDF document.
let textLines: Array<TextLine> = extractor.extractTextLinesSync({ startPageIndex: 0, endPageIndex: document.pageCount-1});
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();

Methods

extractImages

//Extract all image information from the PDF document

Returns Promise

extractImages

Extract all image information from the PDF document

Parameter Type Description
options Object The options to specify the page range to be selected.

Returns Promise

extractText

Extract text from the PDF document.

Returns Promise

extractText

Extract text from a specified page range in the PDF document with optional layout preservation.

Parameter Type Description
options Object Options to specify the page range to be selected and to extract the text.

Returns Promise

extractTextLines

Extract TextLine collection from all pages of the PDF document.

Returns Promise

extractTextLines

Extract TextLine collection from all pages of the PDF document.

Parameter Type Description
options Object The options to specify the page range to be selected.

Returns Promise

extractTextLinesSync

Extract TextLine collection from all pages of the PDF document, synchronously.

Returns TextLine[]

extractTextLinesSync

Extract TextLine collection from all pages of the PDF document, synchronously

Parameter Type Description
options Object The options to specify the page range to be selected.

Returns TextLine[]

extractTextSync

Extract text from the PDF document, synchronously.

Returns string

extractTextSync

Extract text from a specified page range in the PDF document with optional layout preservation, synchronously.

Parameter Type Description
options Object Options to specify the page range to be selected and to extract the text.

Returns string

findText

Searches for text in the PDF document and returns the bounding rectangles
of all matches grouped by page number.

Parameter Type Description
searchText string The text to search for in the PDF document.
options (optional) TextSearchOptions The text search options.

Returns Promise

findText

Searches for a collection of text values in the PDF document and returns
the bounding rectangles of all matches grouped by page number.

Parameter Type Description
searchText string[] The collection of text values to search for
in the PDF document.
options (optional) TextSearchOptions The text search options.

Returns Promise

findTextSync

Searches for text in the PDF document and returns the bounding rectangles
of all matches grouped by page number, synchronously.

Parameter Type Description
searchText string The text to search for in the PDF document.
options (optional) TextSearchOptions The text search options.

Returns TextSearchResult

findTextSync

Searches for a text collection in the PDF document and returns the text
search results that specify the bounding rectangles of all matches
grouped by page number, synchronously.

Parameter Type Description
searchText string[] The collection of text values to search for
in the PDF document.
options (optional) TextSearchOptions The text search options.

Returns TextSearchResult[]

getStructureElement

Gets the root structure element of the PDF document.

Returns PdfStructureElement

getStructureElements

Gets the structure elements of PDF page.

Parameter Type Description
page PdfPage PDF page

Returns PdfStructureElement[]