Skip to content

NativePDFiumDocument

@scaryterry/pdfium


Defined in: src/document/native-document.ts:36

A PDF document backed by the native PDFium addon.

Supports core operations: page count, page access, text extraction, rendering, bookmarks, signatures, attachments, and import/export.

get attachmentCount(): number

Defined in: src/document/native-document.ts:308

Get the number of attachments in this document.

number


get disposed(): boolean

Defined in: src/core/disposable.ts:73

Whether this resource has been disposed.

boolean

Disposable.disposed


get fileVersion(): number | undefined

Defined in: src/document/native-document.ts:155

Get the PDF file version (e.g. 14 for PDF 1.4).

number | undefined


get pageCount(): number

Defined in: src/document/native-document.ts:67

Get the number of pages in this document.

number


get pageMode(): PageMode

Defined in: src/document/native-document.ts:173

Get the document’s initial page mode.

PageMode


get rawPermissions(): number

Defined in: src/document/native-document.ts:161

Get the raw document permissions bitmask.

number


get securityHandlerRevision(): number

Defined in: src/document/native-document.ts:180

Get the security handler revision, or -1 if unencrypted.

number


get signatureCount(): number

Defined in: src/document/native-document.ts:238

Get the number of digital signatures in this document.

number


get userPermissions(): number

Defined in: src/document/native-document.ts:167

Get the document user permissions bitmask.

number

[dispose](): void

Defined in: src/core/disposable.ts:148

Dispose of this resource, freeing WASM memory.

This method is idempotent - calling it multiple times has no effect after the first call.

void

Disposable.[dispose]


bookmarks(): IterableIterator<Bookmark>

Defined in: src/document/native-document.ts:219

Iterate over top-level bookmarks lazily.

Each yielded bookmark includes its full subtree of children (eagerly loaded). Use this to avoid building the entire bookmark array up-front.

IterableIterator<Bookmark>


copyViewerPreferences(source): boolean

Defined in: src/document/native-document.ts:385

Copy viewer preferences from another document.

ParameterTypeDescription
sourceNativePDFiumDocumentSource document to copy preferences from

boolean

true if preferences were copied


createNUpDocument(options): NativePDFiumDocument | undefined

Defined in: src/document/native-document.ts:398

Create a new document with N-up layout.

The caller must manage the returned document’s lifecycle.

ParameterType
optionsNUpLayoutOptions

NativePDFiumDocument | undefined

A new document handle, or undefined on failure.


dispose(): void

Defined in: src/core/disposable.ts:164

Alias for Symbol.dispose for explicit calls.

void

document.dispose();

Disposable.dispose


getAttachment(index): PDFAttachment | undefined

Defined in: src/document/native-document.ts:314

Get an attachment by index.

ParameterType
indexnumber

PDFAttachment | undefined


getAttachments(): PDFAttachment[]

Defined in: src/document/native-document.ts:330

Get all attachments.

PDFAttachment[]


getBookmarks(): Bookmark[]

Defined in: src/document/native-document.ts:207

Get the bookmark (outline) tree for this document.

Returns an array of top-level bookmarks, each with nested children. Returns an empty array if the document has no bookmarks.

For large bookmark trees, prefer the lazy bookmarks generator.

Bookmark[]


getMetadata(): DocumentMetadata

Defined in: src/document/native-document.ts:116

Get all standard metadata fields.

DocumentMetadata


getMetaText(tag): string | undefined

Defined in: src/document/native-document.ts:149

Get a specific metadata field by tag name.

ParameterType
tagstring

string | undefined


getPage(pageIndex): NativePDFiumPage

Defined in: src/document/native-document.ts:78

Load a specific page from the document.

ParameterTypeDescription
pageIndexnumberZero-based page index

NativePDFiumPage

The loaded page


getPageLabel(pageIndex): string | undefined

Defined in: src/document/native-document.ts:192

Get the label for a specific page.

ParameterType
pageIndexnumber

string | undefined


getSignature(index): PDFSignature | undefined

Defined in: src/document/native-document.ts:249

Get a digital signature by index.

ParameterType
indexnumber

PDFSignature | undefined


getSignatures(): PDFSignature[]

Defined in: src/document/native-document.ts:276

Get all digital signatures.

PDFSignature[]


hasSignatures(): boolean

Defined in: src/document/native-document.ts:244

Check if this document has digital signatures.

boolean


importPages(source, options): void

Defined in: src/document/native-document.ts:350

Import pages from a source document.

ParameterTypeDescription
sourceNativePDFiumDocumentSource document to import from
optionsImportPagesOptionsImport options (pageRange, insertIndex)

void


importPagesByIndex(source, pageIndices, insertIndex?): void

Defined in: src/document/native-document.ts:367

Import pages by index array.

ParameterTypeDescription
sourceNativePDFiumDocumentSource document to import from
pageIndicesreadonly number[]Zero-based page indices
insertIndex?numberInsertion point (default: end)

void


isTagged(): boolean

Defined in: src/document/native-document.ts:186

Check if the document is tagged (accessible).

boolean


pages(): IterableIterator<NativePDFiumPage>

Defined in: src/document/native-document.ts:106

Iterate over all pages in the document.

Each page is yielded and must be disposed by the caller.

IterableIterator<NativePDFiumPage>


save(options): Uint8Array

Defined in: src/document/native-document.ts:296

Save the document to a byte array.

ParameterTypeDescription
optionsSaveOptionsSave options (flags, version).

Uint8Array

The serialised PDF bytes.