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

Examples

import { PdfFile } from "@intuned/sdk/files"

const pdf = new PdfFile(pdfBuffer);

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

import { PdfFile } from "@intuned/sdk/files"

const pdf = await PdfFile.fromUrl('https://example.com/file.pdf');
const content = await pdf.getContent([1, 2, 3]);
console.log(content);

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

import { PdfFile } from "@intuned/sdk/files"

const pdf = await PdfFile.fromUrl('https://example.com/file.pdf');
const pageCount = await pdf.pagesCount();
console.log(pageCount);

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

import { PdfFile } from "@intuned/sdk/files"

const pdf = await PdfFile.fromUrl('https://example.com/file.pdf');
const results = await pdf.search('keyword');

console.log(results);

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

import { PdfFile } from "@intuned/sdk/files"

const pdf = await PdfFile.fromUrl('https://example.com/file.pdf');