Class: DocumentViewer

core. DocumentViewer

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


new DocumentViewer()

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

Extends

Members


currentPageNumber

The current page number being displayed.


isDocumentModified

Whether the document has been modified.


pagesCount

The number of pages in the document.


pagesRotation

The rotation of the pages in the document.


scale

The current scale of the document.

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:

clearSearchResults()

Clear the search results in the document.


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>

exportFormXfdf()

Export the form annotations in the document as XFDF.

Returns:

The XFDF string of the exported form annotations.

Type
Promise.<string>

exportPDF(saveAs)

Export the document as a PDF.

Parameters:
Name Type Description
saveAs boolean

Whether to save as the document.

Returns:

The ArrayBuffer of the exported PDF.

Type
Promise.<ArrayBuffer>

exportXfdf()

Export the annotations in the document as XFDF.

Returns:

The XFDF string of the exported annotations.

Type
Promise.<string>

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>

flattenPdf()

Flatten the annotations in the document.

Returns:

The ArrayBuffer of the flattened PDF.

Type
Promise.<ArrayBuffer>

getActiveSearchResult()

Get the active search result in the document.

Returns:

The active search result object.

Type
object

getAnnotationHistoryManager()

Get the AnnotationHistoryManager for the document.

Returns:

The AnnotationHistoryManager for the document.

Type
AnnotationHistoryManager

getAnnotationManager()

Get the AnnotationManager for the document.

Returns:

The AnnotationManager for the document.

Type
AnnotationManager

getBookmarks()

Get the bookmarks in the document.

Returns:

The bookmarks in the document.

Type
Array.<object>

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

getPageSearchResults(pageNumber)

Get the search results on a specified page in the document.

Parameters:
Name Type Description
pageNumber number

The page number to get the search results from.

Returns:

The search results on the specified page.

Type
Array.<object>

getPageTextContent(pageNumber)

Get the text content of a specified page in the document.

Parameters:
Name Type Description
pageNumber number

The page number to get the text content from.

Returns:

The text content of the specified page.

Type
Promise.<string>

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(mousePoint1, mousePoint2)

Get the page number of the page that contains the specified points.

Parameters:
Name Type Description
mousePoint1 object

The first point.

Properties
Name Type Description
x number

The x coordinate of the first point.

y number

The y coordinate of the first point.

mousePoint2 object

The second point.

Properties
Name Type Description
x number

The x coordinate of the second point.

y number

The y coordinate of the second point.

Returns:

The first selected page and last selected page.

Type
object

getSelectedText()

Get the selected text in the document.

Returns:

The selected text.

Type
string

getSelectedTextQuads()

Get the quads of the selected text in the document.

Returns:

The quads of the selected text.

Type
Array.<Object>

getViewerElement()

Get the viewer element of the web viewer.

Returns:

The viewer element.

Type
HTMLElement

getWebFontNameList()

Get the list of web font names imported in the document.

Returns:

The list of web font names.

Type
Promise.<Array.<string>>

importAnnotations(annotations)

Import from annotations into the document.

Parameters:
Name Type Description
annotations string | File

The XFDF string or ArrayBuffer to import.


importFormAnnotations(formAnnotations)

Import form annotations into the document.

Parameters:
Name Type Description
formAnnotations string | File

The XFDF string or ArrayBuffer to import.


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.


jumpToAnnotation(annotation)

Jump to the specified annotation in the document.

Parameters:
Name Type Description
annotation Annotation

The annotation to jump to.


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(position)

Scroll the web viewer to the specified position.

Parameters:
Name Type Description
position object

The position to scroll to.

Properties
Name Type Description
left number

The left coordinate to scroll to.

top number

The top coordinate to scroll to.


scrollToPercent(position)

Scroll the web viewer to the specified percentage position.

Parameters:
Name Type Description
position object

The percentage position to scroll to.

Properties
Name Type Description
left number

The horizontal percentage to scroll to (0 to 1).

top number

The vertical percentage to scroll to (0 to 1).


Searche the document for the specified text.

Parameters:
Name Type Description
text string

The Searched Content.

Returns:

The search result object.

Type
Promise.<object>

searchInPage(text, pageNumber)

Search the specified page in the document for the specified text.

Parameters:
Name Type Description
text string

The Searched Content.

pageNumber number

The page number to search in.

Returns:

The search result object.

Type
Promise.<object>

setActiveSearchResult(searchResult)

Set the active search result in the document.

Parameters:
Name Type Description
searchResult object

The search result to set as active.


setCurrentPage(pageNumber)

Set the current page in the web viewer.

Parameters:
Name Type Description
pageNumber number

The page number to set as current.


setErrorCallback(callback)

Set the error callback for the document.

Parameters:
Name Type Description
callback function

The callback function to set.

Returns:

The error object.

Type
object

setPassword(password)

Set the password for the document.

Parameters:
Name Type Description
password string

The password to set.


setSearchHighlightColors(colors)

Set the highlight colors for search results in the document.

Parameters:
Name Type Description
colors object

The colors to set for highlighting search results.

Properties
Name Type Argument Description
searchResult string <optional>

The color to highlight the search results.

activeSearchResult string <optional>

The color to highlight the active search result.


setTool(toolName)

Set the current tool in the web viewer.

Parameters:
Name Type Description
toolName 'addText' | 'addImage' | 'cropPage' | 'redaction' | 'remove' | 'signatureFields' | 'addDigitalSign' | 'addElectronicSign' | 'pan' | 'selectText' | 'text' | 'ink' | 'highlight' | 'underline' | 'strikeout' | 'squiggly' | 'circle' | 'arc' | 'square' | 'polygon' | 'cloudy' | 'polyline' | 'arrow' | 'line' | 'freetext' | 'callout' | 'image' | 'link' | 'textfield' | 'checkbox' | 'radiobutton' | 'listbox' | 'combobox' | 'pushbutton' | 'lineMeasurement' | 'polylineMeasurement' | 'curveMeasurement' | 'arcMeasurement' | 'circleMeasurement' | 'rectangleMeasurement' | 'polygonMeasurement'

The name of the tool 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.

Events


annotationChanged

Triggered when an annotation is added, modified, or deleted.

Properties:
Name Type Description
action string

The action that was changed. Can be "add", "modify", or "delete".

annotations Array.<Annotation>

The annotations that were changed.


annotationDeselected

Triggered when an annotation is deselected.

Properties:
Name Type Description
annotation Annotation

The annotation that was deselected.


annotationSelected

Triggered when an annotation is selected.

Properties:
Name Type Description
annotation Annotation

The annotation that was selected.


click

Triggered when the document viewer is clicked.

Properties:
Name Type Description
event object

The click event object.


contentBoxDeselected

Triggered when a content box is deselected.


contentBoxSelected

Triggered when a content box is selected.

Properties:
Name Type Description
data object

The data object.

Properties
Name Type Description
type 'text' | 'image'

The type of content box selected.

pageNumber object

The page number of the content box.


dblclick

Triggered when the document viewer is double clicked.

Properties:
Name Type Description
event object

The double click event object.


deleteReply

Triggered when a reply to an annotation is deleted.

Properties:
Name Type Description
annotation Annotation

The reply annotation that was deleted.


documentloaded

Triggered when a document is loaded.


mouseMove

Triggered when the mouse is moved over the document viewer.

Properties:
Name Type Description
event object

The mouse move event object.


pageCropped

Triggered when a page is cropped.

Properties:
Name Type Description
data object

The data object.

Properties
Name Type Description
pageNumber number

The page number that was cropped.

rect object

The crop box of the page.


pageNumberUpdated

Triggered when the current page number is updated.

Properties:
Name Type Description
pageNumber number

The current page number.


scalechanging

Triggered when the scale is changing.

Properties:
Name Type Description
data object

The data object.

Properties
Name Type Description
scale number

The new scale value.


textSelected

Triggered when text is selected in the document viewer.

Properties:
Name Type Description
data object

The data object.

Properties
Name Type Description
selectedText string

The selected text.

textRects Array.<Object>

The quads of the selected text.

pageNumber number

The page number of the selected text.


toolChanged

Triggered when the current tool is changed.

Properties:
Name Type Description
tool string

The name of the tool.


updateAnnotationPermission

Triggered when the permission of an annotation is updated.