Represents a PDF file and provides methods to interact with it.

Examples

Constructors

new PdfFile()

new PdfFile(data): PdfFile

Creates an instance of PdfFile.

Parameters

data: Buffer

The binary data of the PDF file.

Returns

PdfFile

Methods

getContent()

getContent(pageNumbers?): Promise<PdfFileContentItem[]>

Gets the text content of specified pages in the PDF file. Does not support links.

Parameters

pageNumbers?: number[]

Optional. An array of page numbers to get content from.

Returns

Promise<PdfFileContentItem[]>

A promise that resolves to the content of the specified pages.

Examples


pagesCount()

pagesCount(): Promise<number>

Gets the total number of pages in the PDF file.

Returns

Promise<number>

A promise that resolves to the number of pages.

Examples


search(search, options?): Promise<SearchPdfResult[]>

Searches for a string within the PDF file.

Parameters

search: string

The string to search for.

options?: SearchPdfConfigs

Optional. Search configuration options.

Returns

Promise<SearchPdfResult[]>

A promise that resolves to an array of search results.

Examples


fromUrl()

static fromUrl(url): Promise<PdfFile>

Creates a PdfFile instance from a URL.

Parameters

url: string

The URL of the PDF file.

Returns

Promise<PdfFile>

A promise that resolves to a PdfFile instance.

Examples