Class: DocumentView
Class for managing the presentation and interaction with a PDF document within a container element.
Extends
Implements
Constructors
new DocumentView()
new DocumentView(
container,options?):DocumentView
Constructor for the DocumentView class.
Parameters
• container: HTMLElement
The container element in which the document view will be displayed.
• options?: DocumentViewOptions
Returns
Overrides
Properties
DEFAULT_DPI
readonlystaticDEFAULT_DPI:number
Accessors
accessibilityLayerEnabled
getaccessibilityLayerEnabled():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.
setaccessibilityLayerEnabled(v):void
Parameters
• v: boolean
Returns
boolean
currentPageNumber
getcurrentPageNumber():number
Gets or sets the currently most visible page.
setcurrentPageNumber(pageNumber):void
Parameters
• pageNumber: number
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.
dpi
getdpi():number
Gets the dpi (Dots Per Inch) value which influences the rendering resolution of a document view.
Higher DPI values result in higher resolution images, which can make them appear sharper and more detailed.
Default Value
window.devicePixelRatio * 96
Returns
number
firstVisiblePageNumber
getfirstVisiblePageNumber():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
getfitMode():FitMode
Experimental
Gets or sets the fit mode for the document view.
setfitMode(fitMode):void
Parameters
• fitMode: FitMode
Returns
lastVisiblePageNumber
getlastVisiblePageNumber():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
getpageLayoutMode():PageLayoutMode
Experimental
Gets or sets the page layout mode for the document view.
setpageLayoutMode(pageLayoutMode):void
Parameters
• pageLayoutMode: PageLayoutMode
Returns
pdfDocument
getpdfDocument():Document
Gets Pdf.Document attached to the DocumentView.
Returns
rotation
getrotation():Rotation
Experimental
Gets or sets the rotation for the document view.
setrotation(rotation):void
Parameters
• rotation: Rotation
Returns
scrollAllowance
getscrollAllowance():ScrollAllowance
Get the current scroll allowances
Returns
ScrollAllowance
scrollContainer
getscrollContainer():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
getslidingWindow():Map<number,DocumentViewPage>
Gets pages in sliding window.
Returns
Map<number, DocumentViewPage>
viewport
getviewport():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
getzoom():number
Gets or sets the currently used zoom factor as a floating-point number. 1 corresponds to a zoom level of 100%.
setzoom(zoom):void
Parameters
• zoom: number
Returns
number
Zoom level or null if the document view is not initialized.
zoomLevels
getzoomLevels():number[]
Gets or sets the array of zoom levels available for the document view.
setzoomLevels(zoomLevels):void
Parameters
• zoomLevels: number[]
Returns
number[]
Methods
addEventListener()
addEventListener<
K>(type,listener):void
Register a function that will be called whenever the specified event is delivered.
Type Parameters
• 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
The function that will be executed when an event of the specified type occurs.
Returns
void
Inherited from
dispatchEvent()
dispatchEvent<
K>(type,args):void
Dispatches an event to all registered listeners.
Type Parameters
• 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
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
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 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 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
The event listener function of the event handler to remove from the event target.
Returns
void