Skip to main content
Version: Version 5

Interface: UIDocumentView

Class for managing the presentation and interaction with a PDF document within a container element.

Extends​

  • EventEmitter<DocumentViewEventMap>

Implements​

Accessors​

accessibilityLayerEnabled​

Get Signature​

get accessibilityLayerEnabled(): boolean

Enables or disables the accessibility layer for the document view.

When enabled, the accessibility layer provides support for screen readers and other accessibility tools by creating an invisible HTML structure that aligns with the text fragments on the page.

Returns​

boolean

Set Signature​

set accessibilityLayerEnabled(v): void

Parameters​
v​

boolean

Returns​

void


currentPageNumber​

Get Signature​

get currentPageNumber(): number

Gets or sets the currently most visible page.

Returns​

number

The number of the page which covers the largest area on the viewport, or null if the document view is not initialized. If multiple pages cover the same amount of space, the one with the smaller page number is returned.

Set Signature​

set currentPageNumber(pageNumber): void

Parameters​
pageNumber​

number

Returns​

void


devicePixelRatio​

Get Signature​

get devicePixelRatio(): number

Gets the device pixel ratio used for rendering.

Returns​

number


firstVisiblePageNumber​

Get Signature​

get firstVisiblePageNumber(): number

Gets the page number of the first visible page in the document view.

Returns​

number

The page number of the first visible page, or null if the document view is not initialized.


fitMode​

Get Signature​

get fitMode(): FitMode

Experimental

Gets or sets the fit mode for the document view.

Returns​

FitMode

Set Signature​

set fitMode(fitMode): void

Parameters​
fitMode​

FitMode

Returns​

void


lastVisiblePageNumber​

Get Signature​

get lastVisiblePageNumber(): number

Gets the page number of the last visible page in the document view.

Returns​

number

The page number of the last visible page, or null if the document view is not initialized.


pageLayoutMode​

Get Signature​

get pageLayoutMode(): PageLayoutMode

Experimental

Gets or sets the page layout mode for the document view.

Returns​

PageLayoutMode

Set Signature​

set pageLayoutMode(pageLayoutMode): void

Parameters​
pageLayoutMode​

PageLayoutMode

Returns​

void


pdfDocument​

Get Signature​

get pdfDocument(): Document

Gets Pdf.Document attached to the DocumentView.

Returns​

Document


rotation​

Get Signature​

get rotation(): Rotation

Experimental

Gets or sets the rotation for the document view.

Returns​

Rotation

Set Signature​

set rotation(rotation): void

Parameters​
rotation​

Rotation

Returns​

void


scrollAllowance​

Get Signature​

get scrollAllowance(): ScrollAllowance

Get the current scroll allowances

Returns​

ScrollAllowance


scrollContainer​

Get Signature​

get scrollContainer(): HTMLDivElement

Retrieves the scroll container element.

The scroll container holds the individual PDF pages within the viewport. This element manages the scrolling behavior and allows navigation through different pages of the PDF document.

Returns​

HTMLDivElement

The scroll container element.


slidingWindow​

Get Signature​

get slidingWindow(): Map<number, DocumentViewPage>

Gets pages in sliding window.

Returns​

Map<number, DocumentViewPage>


viewport​

Get Signature​

get viewport(): HTMLDivElement

Retrieves the viewport element.

The viewport represents the entire document view of the PDF. It acts as the main container that defines the visible area of the PDF document.

Returns​

HTMLDivElement

The viewport container element.


zoom​

Get Signature​

get zoom(): number

Gets or sets the currently used zoom factor as a floating-point number. 1 corresponds to a zoom level of 100%.

Returns​

number

Zoom level or null if the document view is not initialized.

Set Signature​

set zoom(zoom): void

Parameters​
zoom​

number

Returns​

void


zoomLevels​

Get Signature​

get zoomLevels(): number[]

Gets or sets the array of zoom levels available for the document view.

Returns​

number[]

Set Signature​

set zoomLevels(zoomLevels): void

Parameters​
zoomLevels​

number[]

Returns​

void

Methods​

addEventListener()​

addEventListener<K>(type, listener): void

Register a function that will be called whenever the specified event is delivered.

Type Parameters​

K​

K extends keyof DocumentViewEventMap

A generic type representing the key of the event type.

Parameters​

type​

K

String representing the event type to listen for.

listener​

(…e) => void

The function that will be executed when an event of the specified type occurs.

Returns​

void

Inherited from​

EventEmitter.addEventListener


dispatchEvent()​

dispatchEvent<K>(type, args): void

Dispatches an event to all registered listeners.

Type Parameters​

K​

K extends keyof DocumentViewEventMap

A generic type representing the key of the event type.

Parameters​

type​

K

String representing the event type to dispatch.

args​

Parameters<DocumentViewEventMap[K]>

The data associated with the event.

Returns​

void

Inherited from​

EventEmitter.dispatchEvent


dispose()​

dispose(): void

Disposes of the object, releasing any resources it holds.

The dispose method is responsible for performing cleanup operations and releasing any resources acquired by the object. Once an object is disposed, it should not be used, and attempts to do so may result in undefined behavior.

Returns​

void

Implementation of​

Disposable.dispose


goToDestination()​

goToDestination(destination): void

Navigates to the specified destination in the document view.

Parameters​

destination​

Destination

The destination to navigate to.

Returns​

void


goToPage()​

goToPage(pageNumber): any

Navigates to the specified page in the document view.

Parameters​

pageNumber​

number

The page number to navigate to.

Returns​

any


initialize()​

initialize(pdfDocument): void

Initializes the document view.

Parameters​

pdfDocument​

Document

The PDF document which will be displayed inside the document view.

Returns​

void


nextPage()​

nextPage(): any

Navigates to the next page in the document view.

Returns​

any


previousPage()​

previousPage(): any

Navigates to the previous page in the document view.

Returns​

any


removeAllListeners()​

removeAllListeners<K>(type): void

Remove all listeners for a given event.

Type Parameters​

K​

K extends keyof DocumentViewEventMap

A generic type representing the key of the event type.

Parameters​

type​

K

String representing the event for which to remove all listeners.

Returns​

void

Inherited from​

EventEmitter.removeAllListeners


removeEventListener()​

removeEventListener<K>(type, listener): void

Removes an event listener previously registered with addEventListener.

Type Parameters​

K​

K extends keyof DocumentViewEventMap

A generic type representing the key of the event type.

Parameters​

type​

K

String representing the event for which to remove an event listener.

listener​

(…e) => void

The event listener function of the event handler to remove from the event target.

Returns​

void

Inherited from​

EventEmitter.removeEventListener