Class: ComPDFKitViewer

core. ComPDFKitViewer

The Document class is used to load and display documents in the DocumentViewer control.


new ComPDFKitViewer()

Constructs a new empty Document, representing a document with individual pages that can be displayed on screen and printed.

Extends

Methods


addAnnotations(annotation)

Add annotations to the document.

Parameters:
Name Type Description
annotation object

The object containing the annotation to add.


addEvent(eventName, listener [, options])

Parameters:
Name Type Argument Description
eventName string

The name of the event to listen for.

listener function

The function to call when the event is dispatched.

options object <optional>

The options for the event listener.

Properties
Name Type Description
once boolean

Whether the listener should only be called once.

Inherited From:

copyPages(pagesIndexToCopy)

Copy pages in the document.

Parameters:
Name Type Description
pagesIndexToCopy Array.<number>

The index of the pages to copy.


dispatch(eventName, data)

Parameters:
Name Type Description
eventName string

The name of the event to dispatch.

data *

The data to pass to the event listeners.

Inherited From:

download()

Download the document as an ArrayBuffer.

Returns:
Type
Promise.<ArrayBuffer>

extractPages(pagesIndexToExtract)

Extract pages from the document.

Parameters:
Name Type Description
pagesIndexToExtract Array.<(number|string)>

The index of the pages to extract.

Returns:

The ArrayBuffer of the extracted pages.

Type
Promise.<ArrayBuffer>

getPageHeight(pageNumber)

Get the height of a specified page in the document.

Parameters:
Name Type Description
pageNumber number

The page number to get the height of.

Returns:

The height of the page

Type
number

getPageWidth(pageNumber)

Get the width of a specified page in the document.

Parameters:
Name Type Description
pageNumber number

The page number to get the width of.

Returns:

The width of the page

Type
number

getScrollViewElement()

Get the scroll view element of the web viewer.

Returns:

The scroll view element.

Type
HTMLElement

getSelectedPage(windowCoordinates)

Get the selected page of the web viewer.

Parameters:
Name Type Description
windowCoordinates object

The window coordinates to convert.

Properties
Name Type Description
x number

The x coordinate of the point.

y number

The y coordinate of the point.

Returns:

The selected page.

Type
number

insertBlankPage(pageIndex, width, height)

Insert a blank page into the document.

Parameters:
Name Type Description
pageIndex number

The index to insert the blank page at.

width number

The width of the blank page.

height number

The height of the blank page.


insertPages(file, pageIndexToInsert, pagesIndexToInsert)

Insert pages into the document.

Parameters:
Name Type Description
file File

The file to insert.

pageIndexToInsert number

The index to insert the pages at.

pagesIndexToInsert Array.<(number|string)>

The index of the pages to insert.


movePages(pagesIndexToMove, targetPageIndex)

Move pages in the document.

Parameters:
Name Type Description
pagesIndexToMove string

The index of the pages to move.

targetPageIndex number

The index to move the pages to.


nextPage()

Display the next page in the web viewer.


pageNumberChanged(pageNumber)

Display the specified page in the web viewer.

Parameters:
Name Type Description
pageNumber string

The page number to display.


pageToWindow(pagePoint, pageNumber)

Convert a point from page coordinates to window coordinates.

Parameters:
Name Type Description
pagePoint object

The point to convert.

Properties
Name Type Description
x number

The x coordinate of the point.

y number

The y coordinate of the point.

pageNumber number

The page number of the point.

Returns:

The converted point.

Type
object

previousPage()

Display the previous page in the web viewer.


removeEvent(eventName, listener)

Parameters:
Name Type Description
eventName string

The name of the event to remove listening for.

listener function

The function to remove from the event listeners.

Inherited From:

removePages(pagesIndexToDelete)

Remove pages from the document.

Parameters:
Name Type Description
pagesIndexToDelete Array.<number>

The index of the pages to remove.


removePassword()

Remove the password from the document.


requestFullScreenMode()

Request full screen mode for the web viewer.


rotatePages(pagesIndexToRotate, rotation)

Rotate pages in the document.

Parameters:
Name Type Description
pagesIndexToRotate Array.<number>

The index of the pages to rotate.

rotation number

The rotation to apply to the pages.


scrollTo()

Scroll the web viewer to the specified position.


Searche the document for the specified text.

Parameters:
Name Type Description
text string

The Searched Content.


setPassword(password)

Set the password for the document.

Parameters:
Name Type Description
password string

The password to set.


webViewerScaleChanged(scale)

Change the scale of the web viewer.

Parameters:
Name Type Description
scale number

The scale to change to.


webViewerSwitchScrollMode(mode)

Switche the scroll mode of the web viewer.

Parameters:
Name Type Description
mode 0 | 1

Scroll Mode Parameter, Vertical Mode: 0, Horizontal Mode: 1


webViewerSwitchSpreadMode(mode)

Switche the display mode of the web viewer.

Parameters:
Name Type Description
mode 0 | 1 | 2

Display Mode Parameter, Single Mode: 0, Two-up Mode: 1, Cover Mode: 2


windowToPage(windowPoint, pageNumber)

Convert a point from window coordinates to page coordinates.

Parameters:
Name Type Description
windowPoint object

The point to convert.

Properties
Name Type Description
x number

The x coordinate of the point.

y number

The y coordinate of the point.

pageNumber number

The page number of the point.

Returns:

The converted point.

Type
object

zoomIn()

Zoom in the web viewer.


zoomOut()

Zoom out the web viewer.