API Reference

FPdf

Facade for a PDF unit.

Access

Access through:

Setup

Register @univerjs-pro/pdfs or a preset that includes it. In plugin mode, import @univerjs-pro/pdfs/facade. Additional methods below require their listed plugin packages. See Facade setup.

@univerjs-pro/pdfs

FPdf.getDocument

Return the current source PDF document.

TypeScript
getDocument(): IPdfDocument

Returns

The current source document.

Examples

TypeScript
const pdf = univerAPI.getActivePdf()console.log(pdf?.getDocument().pages.length)

Types: IPdfDocument

Package: @univerjs-pro/pdfs · Type definitions

FPdf.getId

Return the PDF unit ID.

TypeScript
getId(): string

Returns

The stable PDF unit ID.

Examples

TypeScript
const pdf = univerAPI.getActivePdf()console.log(pdf?.getId())

Package: @univerjs-pro/pdfs · Type definitions

FPdf.getModel

Return the underlying PDF document model.

TypeScript
getModel(): PdfDocumentModel

Returns

The underlying model.

Examples

TypeScript
const pdf = univerAPI.getActivePdf()console.log(pdf?.getModel().getUnitId())

Types: PdfDocumentModel

Package: @univerjs-pro/pdfs · Type definitions

FPdf.getName

Return the PDF unit name.

TypeScript
getName(): string

Returns

The current PDF unit name.

Examples

TypeScript
const pdf = univerAPI.getActivePdf()console.log(pdf?.getName())

Package: @univerjs-pro/pdfs · Type definitions

FPdf.getPageById

Return a PDF page by ID.

TypeScript
getPageById(id: string): FPdfPage | null

Parameters

  • id — Required. The page ID.

Returns

The page Facade, or null when it does not exist.

Examples

TypeScript
const pdf = univerAPI.getActivePdf()const page = pdf?.getPageById('page-id')console.log(page)

Types: FPdfPage

Package: @univerjs-pro/pdfs · Type definitions

FPdf.getPageByIndex

Return a PDF page by zero-based index.

TypeScript
getPageByIndex(index: number): FPdfPage | null

Parameters

  • index — Required. The zero-based page index.

Returns

The page Facade, or null when the index is out of range.

Examples

TypeScript
const pdf = univerAPI.getActivePdf()const firstPage = pdf?.getPageByIndex(0)console.log(firstPage)

Types: FPdfPage

Package: @univerjs-pro/pdfs · Type definitions

FPdf.getPages

Return all current PDF pages in materialized document order.

TypeScript
getPages(): FPdfPage[]

Returns

The current page Facades.

Examples

TypeScript
const pdf = univerAPI.getActivePdf()console.log(pdf?.getPages())

Types: FPdfPage

Package: @univerjs-pro/pdfs · Type definitions

FPdf.insertPage

Insert a blank PDF page at a zero-based index, or append it when no index is provided.

The new page inherits the adjacent page's size, rotation, and PDF boxes. An A4 page is created when the document has no existing pages.

TypeScript
insertPage(index?: number): FPdfPage

Parameters

  • index — Optional. The zero-based insert index. Omit it to append the page.

Returns

The created page Facade.

Throws

If the index is outside the document page boundaries.

Examples

TypeScript
const pdf = univerAPI.getActivePdf()const page = pdf?.insertPage()console.log(page?.getIndex())

Types: FPdfPage

Package: @univerjs-pro/pdfs · Type definitions

FPdf.save

Save and return a detached PDF unit snapshot.

TypeScript
save(): IPdfUnitData

Returns

The complete current PDF unit snapshot.

Examples

TypeScript
const pdf = univerAPI.getActivePdf()const snapshot = pdf?.save()console.log(snapshot)

Types: IPdfUnitData

Package: @univerjs-pro/pdfs · Type definitions

How is this guide?

© 2026 DreamNum Co., Ltd.