Class CoreControls.DocumentViewer
Represents a full-featured control used for displaying a Document. The viewer supports text selection and text search, and several page view modes.
Constructor Attributes | Constructor Name and Description |
---|---|
Creates a new empty DocumentViewer.
|
Field Attributes | Field Name and Description |
---|---|
Default values for document viewer.
|
Method Attributes | Method Name and Description |
---|---|
Clears any selected text on the all pages.
|
|
Reinitializes data and clears the viewer area content.
|
|
DisplayBookmark(bookmark)
If the boomark is an internal link then it scrolls the viewer so that the position of the bookmark is in the upper-left corner of the viewer.
|
|
Scrolls the viewer so that the upper-left corner of the Document's first page is in the upper-left corner of the viewer.
|
|
Scrolls the viewer so that the upper-left corner of the Document's last page is in the upper-left corner of the viewer.
|
|
DisplaySearchResult(result, jump)
Scrolls the viewer so that the position of the search result is in the middle of the viewer.
|
|
Dispose()
Disposes the current document's data
|
|
DrawSelection(pageNumber)
Draws the text selection for the specified page.
|
|
Returns the AnnotationManager used by this DocumentViewer
|
|
Returns the current page number
|
|
Returns the DisplayModeManager used by this DocumentViewer
|
|
Returns the Document that is currently being displayed by the viewer.
|
|
Returns the current fit mode.
|
|
Returns a pixel value, representing the left, right, top and bottom margins.
|
|
Returns the number of pages in a document.
|
|
Gets the individual page rotations of the document.
|
|
GetPageZoom(pageIndex)
Get the zoom value for a particular page.
|
|
GetRotation(pageNumber)
Returns the current viewing rotation.
|
|
Returns the text selected by text selection tool or search.
|
|
Returns the current tool.
|
|
GetZoom()
Returns the current zoom level
|
|
LoadAsync(partRetriever, docId)
Initialize the viewer and load a .xod document into the viewer.
|
|
RemoveContent(removeData, rotationChanged)
Removes all the page content from the DOM.
|
|
ReturnCanvas(pageIndex, canvas)
Returns the canvas so that it can be reused.
|
|
RotateClockwise(pageNumber)
Rotates all pages in the currently displayed document clockwise by 90 degrees.
|
|
RotateCounterClockwise(pageNumber)
Rotates all pages in the currently displayed document counter-clockwise by 90 degrees.
|
|
This function must be called after modifying the ScrollView (#DocumentViewer) element's dimensions or properties.
|
|
Select(pt1, pt2)
Selects the text content of the document given two page coordinates.
|
|
SetCurrentPage(pageNumber)
Sets the current page.
|
|
SetFitMode(fitMode)
Sets how the document will scale to fit the size of the scrollviewer's viewport.
|
|
SetMargin(margin)
Set the pixel value to use for the left, right, top and bottom margins.
|
|
SetOptions(options)
Sets specific DocumentViewer options.
|
|
SetPageRotations(rotations)
Sets the individual page rotations of multiple pages at once.
|
|
SetPagesPerCanvas(value)
Sets the number of pages that will be visible on each canvas.
|
|
SetPageZoom(pageIndex, zoom)
Sets the zoom for a particular page.
|
|
SetRotation(pageNumber, pageRotation)
Sets the current viewing rotation.
|
|
SetTextHighlightColor(color)
Sets the color to use when highlighting text from text selection or searching.
|
|
SetToolMode(toolMode)
Sets the tool mode.
|
|
StopPageRender(pageIndex)
Stops the rendering of the specified page.
|
|
TextSearchInit(pattern, mode, fullSearch, onSearchCallback(result))
Searches for a particular text string on the currently displayed Document, starting on the current page.
|
|
UpdateLinks(pageIndex)
Updates all of the links on the page.
|
|
UpdateView(visiblePages, currentPageIndex)
Removes previously drawn pages that are no longer visible and
draws pages that are visible and have not been drawn.
|
|
Notifies the document viewer that the visible pages have changed
but does not draw any pages.
|
|
ZoomTo(zoom, x, y)
Adjusts the viewer's zoom factor, and positions the point (x,y) at the upper left corner of the viewer.
|
Event Attributes | Event Name and Description |
---|---|
changePage(evt, pageNum)
Triggered when the page should be changed
|
|
dblClick(evt, nativeEvt)
Triggered for the dblClick event in the DocumentViewer's viewing area
|
|
displayModeUpdated(evt)
Triggered when the display mode is updated
|
|
displayPageLocation(evt, pageNum, verticalOffset, horizontalOffset)
Triggered when a page location should be displayed
|
|
documentLoaded(evt)
Triggered when the document has been loaded
|
|
fitModeUpdated(evt, fitMode)
Triggered when the fit mode has changed
|
|
keyDown(evt, nativeEvt)
Triggered for the keyDown event in the DocumentViewer's viewing area
|
|
keyUp(evt, nativeEvt)
Triggered for the keyUp event in the DocumentViewer's viewing area
|
|
linkReady(evt, linkElement, link)
Triggered when a link is created on the page.
|
|
mouseEnter(evt, nativeEvt)
Triggered for the mouseEnter event in the DocumentViewer's viewing area
|
|
mouseLeave(evt, nativeEvt)
Triggered for the mouseLeave event in the DocumentViewer's viewing area
|
|
mouseLeftDown(evt, nativeEvt)
Triggered for the mouseLeftButtonDown event in the DocumentViewer's viewing area
Attach like docViewer.on('mouseLeftDown', callback)
|
|
mouseLeftUp(evt, nativeEvt)
Triggered for the mouseLeftButtonUp event in the DocumentViewer's viewing area
|
|
mouseMove(evt, nativeEvt)
Triggered for the mouseMove event in the DocumentViewer's viewing area
|
|
mouseRightDown(evt, nativeEvt)
Triggered for the mouseRightButtonDown event in the DocumentViewer's viewing area
|
|
mouseRightUp(evt, nativeEvt)
Triggered for the mouseRightButtonUp event in the DocumentViewer's viewing area
|
|
pageComplete(evt, pageIndex, canvas)
Triggered when a page has been completely rendered.
|
|
pageNumberUpdated(evt, pageNumber)
Triggered when the page number is updated
|
|
rotationUpdated(evt, rotation, pageNumber)
Triggered when the page rotation has changed
|
|
textSelected(evt, quads, text)
Triggered when the selected text has changed
|
|
toolModeUpdated(evt, toolModeClass)
Triggered when the tool mode has changed
|
|
zoomUpdated(evt, zoom)
Triggered when the zoom level has been updated
|
Field Detail
{object}
defaults
Default values for document viewer. Set FitMode, DisplayMode or Zoom.
Method Detail
ClearSelection()
Clears any selected text on the all pages.
CloseDocument()
Reinitializes data and clears the viewer area content.
DisplayBookmark(bookmark)
If the boomark is an internal link then it scrolls the viewer so that the position of the bookmark is in the upper-left corner of the viewer.
If it's an external URL then it opens the URL.
- Parameters:
- {Bookmark} bookmark
- A bookmark that specifies the location to go to. Returned by CoreControls.Document#GetBookmarks.
DisplayFirstPage()
Scrolls the viewer so that the upper-left corner of the Document's first page is in the upper-left corner of the viewer.
DisplayLastPage()
Scrolls the viewer so that the upper-left corner of the Document's last page is in the upper-left corner of the viewer.
DisplaySearchResult(result, jump)
Scrolls the viewer so that the position of the search result is in the middle of the viewer.
- Parameters:
- {Object} result
- The result of a search, DocumentViewer.SearchResults. Returned by onSearchCallback in CoreControls.DocumentViewer#TextSearchInit.
- {function} jump
- The callback for navigating to the found result.
Dispose()
Disposes the current document's data
DrawSelection(pageNumber)
Draws the text selection for the specified page. Should be called after calling
AnnotationManager's DrawAnnotations function if the selection should still be shown.
- Parameters:
- {number} pageNumber
- The page number to draw the selection on
{AnnotationManager}
GetAnnotationManager()
Returns the AnnotationManager used by this DocumentViewer
- Returns:
- {AnnotationManager} an instance of AnnotationManager
{number}
GetCurrentPage()
Returns the current page number
- Returns:
- {number} The current 1-indexed page number.
{DisplayModeManager}
GetDisplayModeManager()
Returns the DisplayModeManager used by this DocumentViewer
- Returns:
- {DisplayModeManager} an instance of DisplayModeManager
{CoreControls.Document}
GetDocument()
Returns the Document that is currently being displayed by the viewer.
- Returns:
- {CoreControls.Document} returns the current document.
{DocumentViewer.FitMode}
GetFitMode()
Returns the current fit mode.
- Returns:
- {DocumentViewer.FitMode} The current fit mode.
{number}
GetMargin()
Returns a pixel value, representing the left, right, top and bottom margins.
- Returns:
- {number} The margin value.
{number}
GetPageCount()
Returns the number of pages in a document.
- Returns:
- {number} The number of the pages in the current document.
{object}
GetPageRotations()
Gets the individual page rotations of the document. Only returns pages that have been rotated individually.
- Returns:
- {object} An object with keys that are page indexes (0-indexed) and values that are rotation values.
GetPageZoom(pageIndex)
Get the zoom value for a particular page.
- Parameters:
- {int} pageIndex
- The page index.
{CoreControls.PageRotation}
GetRotation(pageNumber)
Returns the current viewing rotation.
PageRotation.e_0 = 0 (0 degress)
PageRotation.e_90 = 1 (90 degress)
PageRotation.e_180 = 2 (180 degress)
PageRotation.e_270 = 3 (270 degress)
- Parameters:
- {number} pageNumber Optional
- Optionally pass the page number to get the specific page's rotation
- Returns:
- {CoreControls.PageRotation} The current viewing rotation.
{string}
GetSelectedText()
Returns the text selected by text selection tool or search.
- Returns:
- {string} Selected text.
{window.Tools}
GetToolMode()
Returns the current tool.
- Returns:
- {window.Tools} The current tool mode.
{number}
GetZoom()
Returns the current zoom level
- Returns:
- {number} The current zoom level.
LoadAsync(partRetriever, docId)
Initialize the viewer and load a .xod document into the viewer.
- Parameters:
- {HttpPartRetriever|LocalPartRetriever|StreamingPartRetriever} partRetriever
- An instance of PartRetriever.
- {string} docId
- An optional unique identifier for the document, used for offline mode
RemoveContent(removeData, rotationChanged)
Removes all the page content from the DOM.
Also clear the cache if the zoom or rotation has changed.
- Parameters:
- {bool} removeData
- Whether or not to remove all event handlers and data on the elements
- rotationChanged
ReturnCanvas(pageIndex, canvas)
Returns the canvas so that it can be reused. Should be called when the canvas is no longer used by the viewer.
Only valid in viewport canvas mode.
- Parameters:
- {number} pageIndex
- The page index of the canvas
- {object} canvas
- The canvas element to return
RotateClockwise(pageNumber)
Rotates all pages in the currently displayed document clockwise by 90 degrees.
- Parameters:
- pageNumber
RotateCounterClockwise(pageNumber)
Rotates all pages in the currently displayed document counter-clockwise by 90 degrees.
- Parameters:
- pageNumber
ScrollViewUpdated()
This function must be called after modifying the ScrollView (#DocumentViewer) element's dimensions or properties.
Select(pt1, pt2)
Selects the text content of the document given two page coordinates.
- Parameters:
- pt1
- Starting page coordinate. Requires properties x, y and pageIndex.
- pt2
- Ending page coordinate. Requires properties x, y and pageIndex.
SetCurrentPage(pageNumber)
Sets the current page. Updates the current page and jumps to it.
- Parameters:
- {int} pageNumber
- The page number to jump to.
SetFitMode(fitMode)
Sets how the document will scale to fit the size of the scrollviewer's viewport.
Also re-renders content to the appropriate zoom level.
Only renders if a document has been loaded.
- Parameters:
- {DocumentViewer.FitMode} fitMode
SetMargin(margin)
Set the pixel value to use for the left, right, top and bottom margins.
- Parameters:
- margin
SetOptions(options)
Sets specific DocumentViewer options.
- Parameters:
- {object} options
- An options object, currently valid options are enableAnnotations and annotMode
SetPageRotations(rotations)
Sets the individual page rotations of multiple pages at once. Pages that aren't specified will
use the default document rotation.
- Parameters:
- {object} rotations
- An object with keys that are page indexes (0-indexed) and values that are rotation values. Rotations should be specified as {CoreControls.PageRotation}s
SetPagesPerCanvas(value)
Sets the number of pages that will be visible on each canvas.
Only valid in viewport canvas mode.
- Parameters:
- value
SetPageZoom(pageIndex, zoom)
Sets the zoom for a particular page. Should be followed by a call to UpdateView to actually render the page.
- Parameters:
- {int} pageIndex
- The page index.
- {float} zoom
- Zoom value for page.
SetRotation(pageNumber, pageRotation)
Sets the current viewing rotation.
- Parameters:
- {number} pageNumber Optional
- Optionally pass the page number to set the specific page's rotation
- {CoreControls.PageRotation} pageRotation
- desired viewing rotation.
SetTextHighlightColor(color)
Sets the color to use when highlighting text from text selection or searching.
- Parameters:
- {string} color
- The color to set. eg 'rgba(0, 0, 200, 0.3)'
SetToolMode(toolMode)
Sets the tool mode. Also removes selection caused by text selection or search.
- Parameters:
- {Tools.Tool} toolMode
StopPageRender(pageIndex)
Stops the rendering of the specified page.
- Parameters:
- {number} pageIndex
- The index of the page who's rendering should be stopped.
TextSearchInit(pattern, mode, fullSearch, onSearchCallback(result))
Searches for a particular text string on the currently displayed Document, starting on the current page.
- Parameters:
- {string} pattern
- The text to search for.
- {DocumentViewer.SearchMode} mode
- The options for search, controlling options such as case sensitivity and search direction.
- {boolean} fullSearch
- If true, a search of the entire document will be performed. Otherwise, a single search will be perfomed.
- {function} onSearchCallback(result)
- The callback function to call when the search completes. The search may complete when the search term is found, when the entire document has been searched, and, depending on the search options, at the end of every page. Parameter result: DocumentViewer.SearchResults.
UpdateLinks(pageIndex)
Updates all of the links on the page. This needs to be called after any changes are made to the page's list of links.
Only works with XOD documents that have an internal XFDF document.
- Parameters:
- {number} pageIndex
- The index of the page to update
UpdateView(visiblePages, currentPageIndex)
Removes previously drawn pages that are no longer visible and
draws pages that are visible and have not been drawn.
If visiblePages are provided then those pages are rendered otherwise visiblePages are calculated
depending on where the DIV elements for the pages are located.
- Parameters:
- {Object} visiblePages
- An array of integers representing the pages to render.
- {number} currentPageIndex
- The index of the page that is currently visible in the viewer.
UpdateVisiblePages()
Notifies the document viewer that the visible pages have changed
but does not draw any pages.
ZoomTo(zoom, x, y)
Adjusts the viewer's zoom factor, and positions the point (x,y) at the upper left corner of the viewer.
Only renders if a document has been loaded.
- Parameters:
- {float} zoom
- Zoom value.
- {int} x Optional
- Horizontal position to scroll to.
- {int} y Optional
- Vertical position to scroll to.
Event Detail
changePage(evt, pageNum)
Triggered when the page should be changed
- Parameters:
- {object} evt
- jQuery's event object
- {int} pageNum
- The 1-indexed page number
dblClick(evt, nativeEvt)
Triggered for the dblClick event in the DocumentViewer's viewing area
- Parameters:
- {object} evt
- jQuery's event object
- {object} nativeEvt
- Event object of the native JavaScript event
displayModeUpdated(evt)
Triggered when the display mode is updated
- Parameters:
- {object} evt
- jQuery's event object
displayPageLocation(evt, pageNum, verticalOffset, horizontalOffset)
Triggered when a page location should be displayed
- Parameters:
- {object} evt
- jQuery's event object
- {int} pageNum
- The 1-indexed page number
- {float} verticalOffset
- The offset from the top of the page
- {float} horizontalOffset
- The offset from the left of the page
documentLoaded(evt)
Triggered when the document has been loaded
- Parameters:
- {object} evt
- jQuery's event object
fitModeUpdated(evt, fitMode)
Triggered when the fit mode has changed
- Parameters:
- {object} evt
- jQuery's event object
- {object} fitMode
- The fit mode that has been changed to e.g. docViewer.FitMode.FitWidth
keyDown(evt, nativeEvt)
Triggered for the keyDown event in the DocumentViewer's viewing area
- Parameters:
- {object} evt
- jQuery's event object
- {object} nativeEvt
- Event object of the native JavaScript event
keyUp(evt, nativeEvt)
Triggered for the keyUp event in the DocumentViewer's viewing area
- Parameters:
- {object} evt
- jQuery's event object
- {object} nativeEvt
- Event object of the native JavaScript event
linkReady(evt, linkElement, link)
Triggered when a link is created on the page.
- Parameters:
- {object} evt
- jQuery's event object
- {object} linkElement
- The HTML span element that represents the link
- {object} link
- Link object that contains more information about the link
mouseEnter(evt, nativeEvt)
Triggered for the mouseEnter event in the DocumentViewer's viewing area
- Parameters:
- {object} evt
- jQuery's event object
- {object} nativeEvt
- Event object of the native JavaScript event
mouseLeave(evt, nativeEvt)
Triggered for the mouseLeave event in the DocumentViewer's viewing area
- Parameters:
- {object} evt
- jQuery's event object
- {object} nativeEvt
- Event object of the native JavaScript event
mouseLeftDown(evt, nativeEvt)
Triggered for the mouseLeftButtonDown event in the DocumentViewer's viewing area
Attach like docViewer.on('mouseLeftDown', callback)
- Parameters:
- {object} evt
- jQuery's event object
- {object} nativeEvt
- Event object of the native JavaScript event
mouseLeftUp(evt, nativeEvt)
Triggered for the mouseLeftButtonUp event in the DocumentViewer's viewing area
- Parameters:
- {object} evt
- jQuery's event object
- {object} nativeEvt
- Event object of the native JavaScript event
mouseMove(evt, nativeEvt)
Triggered for the mouseMove event in the DocumentViewer's viewing area
- Parameters:
- {object} evt
- jQuery's event object
- {object} nativeEvt
- Event object of the native JavaScript event
mouseRightDown(evt, nativeEvt)
Triggered for the mouseRightButtonDown event in the DocumentViewer's viewing area
- Parameters:
- {object} evt
- jQuery's event object
- {object} nativeEvt
- Event object of the native JavaScript event
mouseRightUp(evt, nativeEvt)
Triggered for the mouseRightButtonUp event in the DocumentViewer's viewing area
- Parameters:
- {object} evt
- jQuery's event object
- {object} nativeEvt
- Event object of the native JavaScript event
pageComplete(evt, pageIndex, canvas)
Triggered when a page has been completely rendered.
- Parameters:
- {object} evt
- jQuery's event object
- {object} pageIndex
- The 0-indexed page index
- {object} canvas Optional
- The canvas for the page
pageNumberUpdated(evt, pageNumber)
Triggered when the page number is updated
- Parameters:
- {object} evt
- jQuery's event object
- {int} pageNumber
- The new page number (1-indexed)
rotationUpdated(evt, rotation, pageNumber)
Triggered when the page rotation has changed
- Parameters:
- {object} evt
- jQuery's event object
- {CoreControls.PageRotation} rotation
- The new viewing rotation.
- {number} pageNumber Optional
- Optionally the specific page number that had its rotation changed
textSelected(evt, quads, text)
Triggered when the selected text has changed
- Parameters:
- {object} evt
- jQuery's event object
- {array} quads
- An array of bounding box quads of the selected text
- {string} text
- The selected text
toolModeUpdated(evt, toolModeClass)
Triggered when the tool mode has changed
- Parameters:
- {object} evt
- jQuery's event object
- {object} toolModeClass
- The tool mode class that has been changed to.
zoomUpdated(evt, zoom)
Triggered when the zoom level has been updated
- Parameters:
- {object} evt
- jQuery's event object
- {int} zoom
- The new zoom level of the viewer