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.
|
Method Attributes | Method Name and Description |
---|---|
Reinitializes data and clears the viewer area content.
|
|
DisplayBookmark(bookmark)
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.
|
|
Returns the AnnotationManager used by this DocumentViewer
|
|
Returns the current page number
|
|
Returns the current display mode.
|
|
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.
|
|
GetPageZoom(pageIndex)
Get the zoom value for a particular page.
|
|
Returns the current viewing rotation.
|
|
Returns the text selected by text selection tool or search.
|
|
Returns the current tool.
|
|
Returns an array of page indexes that are visible on screen.
|
|
GetZoom()
Returns the current zoom level
|
|
LoadAsync(partRetriever)
Initialize the viewer and load a .xod document into the viewer.
|
|
Removes all the page content from the DOM.
|
|
Rotates all pages in the currently displayed document clockwise by 90 degrees.
|
|
Rotates all pages in the currently displayed document counter-clockwise by 90 degrees.
|
|
Select(pt1, pt2)
Selects the text content of the document given two page coordinates.
|
|
SetAlertCallback(callback)
Sets the callback called in response to permission alerts
|
|
SetCurrentPage(pageNumber)
Sets the current page.
|
|
SetDblClickCallback(callback)
Set a callback for a double click event in the DocumentViewer's viewing area.
|
|
SetDisplayMode(displayMode)
Sets the display mode.
|
|
SetDisplayModeUpdatedCallback(callback)
Sets the function to call after the display mode has been updated.
|
|
SetDisplayPageLocationCallback(callback)
Sets the callback called when a page location should be displayed.
|
|
SetDocumentLoadedCallback(callback)
Sets the callback called in response to the Loaded event of the document.
|
|
SetFitMode(fitMode)
Sets how the document will scale to fit the size of the scrollviewer's viewport.
|
|
SetFitModeUpdatedCallback(callback)
Sets the function to call after the fit mode has been updated.
|
|
SetKeyDownCallback(callback)
Set a callback to a KeyDown event in the DocumentViewer's viewing area.
|
|
SetKeyUpCallback(callback)
Set a callback to a KeyUp event in the DocumentViewer's viewing area.
|
|
SetLinkReadyCallback(callback)
Sets the callback called when a link is created on the page.
|
|
SetMargin(margin)
Set the pixel value to use for the left, right, top and bottom margins.
|
|
SetMouseEnterCallback(callback)
Set a callback to a MouseEnter event in the DocumentViewer's viewing area.
|
|
SetMouseLeaveCallback(callback)
Set a callback to a MouseLeave event in the DocumentViewer's viewing area.
|
|
SetMouseLeftDownCallback(callback)
Set a callback to a MouseLeftButtonDown event in the DocumentViewer's viewing area.
|
|
SetMouseLeftUpCallback(callback)
Set a callback to a MouseLeftButtonUp event in the DocumentViewer's viewing area.
|
|
SetMouseMoveCallback(callback)
Set a callback to a MouseLeave event in the DocumentViewer's viewing area.
|
|
SetMouseRightDownCallback(callback)
Set a callback to a MouseRightButtonDown event in the DocumentViewer's viewing area.
|
|
SetMouseRightUpCallback(callback)
Set a callback to a MouseRightButtonUp event in the DocumentViewer's viewing area.
|
|
SetPageCompleteCallback(callback)
Sets the callback called when a page has been completely rendered.
|
|
SetPageNumberUpdatedCallback(callback)
Sets the function to call after the page number has been updated.
|
|
SetPageZoom(pageIndex, zoom)
Sets the zoom for a particular page.
|
|
SetPermissionCheckCallback(callback)
Sets the callback to perform the permision checking for annotations
|
|
SetRotation(pageRotation)
Sets the current viewing rotation.
|
|
SetTextSelectedCallback(callback)
Sets the function to call after text selection has been changed.
|
|
SetToolMode(toolMode)
Sets the tool mode.
|
|
SetToolModeUpdatedCallback(callback)
Sets the function to call after the tool mode has been updated.
|
|
SetZoomUpdatedCallback(callback)
Sets the function to call after zoom has been updated.
|
|
TextSearchInit(pattern, mode, fullSearch, onSearchCallback(result))
Searches for a particular text string on the currently displayed Document, starting on the current page.
|
|
UpdateView(visiblePages, currentPageIndex)
Removes previously drawn pages that are no longer visible anddraws pages that are visible and have not been drawn.
|
|
ZoomTo(zoom, x, y)
Adjusts the viewer's zoom factor, and positions the point (x,y) at the upper left corner of the viewer.
|
Method Detail
CloseDocument()
Reinitializes data and clears the viewer area content.
DisplayBookmark(bookmark)
Scrolls the viewer so that the position of the bookmark is in the upper-left corner of the viewer.
- Parameters:
- {Bookmark} bookmark
- A bookmark that specifies the location to scroll 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.
{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.
{DocumentViewer.DisplayMode}
GetDisplayMode()
Returns the current display mode.
- Returns:
- {DocumentViewer.DisplayMode} The current display mode.
{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.
GetPageZoom(pageIndex)
Get the zoom value for a particular page.
- Parameters:
- {int} pageIndex
- The page index.
{CoreControls.PageRotation}
GetRotation()
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)
- Returns:
- {CoreControls.PageRotation} The current viewing rotation.
{string}
GetSelectedText()
Returns the text selected by text selection tool or search.
- Returns:
- {string} Selected text.
{DocumentViewer.ToolModes}
GetToolMode()
Returns the current tool.
- Returns:
- {DocumentViewer.ToolModes} The current tool mode.
{number[]}
GetVisiblePages()
Returns an array of page indexes that are visible on screen.
- Returns:
- {number[]} an array of 0-indexed page numbers.
{number}
GetZoom()
Returns the current zoom level
- Returns:
- {number} The current zoom level.
LoadAsync(partRetriever)
Initialize the viewer and load a .xod document into the viewer.
- Parameters:
- {HttpPartRetriever|LocalPartRetriever|StreamingPartRetriever} partRetriever
- An instance of PartRetriever.
RemoveContent()
Removes all the page content from the DOM. Also clear the cache if the zoom or rotation has changed.
RotateClockwise()
Rotates all pages in the currently displayed document clockwise by 90 degrees.
RotateCounterClockwise()
Rotates all pages in the currently displayed document counter-clockwise by 90 degrees.
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.
SetAlertCallback(callback)
Sets the callback called in response to permission alerts
- Parameters:
- {function} callback
SetCurrentPage(pageNumber)
Sets the current page. Updates the current page and jumps to it.
- Parameters:
- {int} pageNumber
- The page number to jump to.
SetDblClickCallback(callback)
Set a callback for a double click event in the DocumentViewer's viewing area.
- Parameters:
- {function} callback
SetDisplayMode(displayMode)
Sets the display mode. Also removes selection caused by text selection or search.Only renders if a document has been loaded.
- Parameters:
- {DocumentViewer.DisplayMode} displayMode
SetDisplayModeUpdatedCallback(callback)
Sets the function to call after the display mode has been updated.
- Parameters:
- {function} callback
SetDisplayPageLocationCallback(callback)
Sets the callback called when a page location should be displayed.
- Parameters:
- {function} callback
SetDocumentLoadedCallback(callback)
Sets the callback called in response to the Loaded event of the document.
- Parameters:
- {function} callback
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
SetFitModeUpdatedCallback(callback)
Sets the function to call after the fit mode has been updated.
- Parameters:
- {function} callback
SetKeyDownCallback(callback)
Set a callback to a KeyDown event in the DocumentViewer's viewing area.
- Parameters:
- {function} callback
SetKeyUpCallback(callback)
Set a callback to a KeyUp event in the DocumentViewer's viewing area.
- Parameters:
- {function} callback
SetLinkReadyCallback(callback)
Sets the callback called when a link is created on the page.The callback argument provides the HTML span element that represents the link, and a Link object that contains more information about the link.
- Parameters:
- {function} callback
SetMargin(margin)
Set the pixel value to use for the left, right, top and bottom margins.
- Parameters:
- margin
SetMouseEnterCallback(callback)
Set a callback to a MouseEnter event in the DocumentViewer's viewing area.
- Parameters:
- {function} callback
SetMouseLeaveCallback(callback)
Set a callback to a MouseLeave event in the DocumentViewer's viewing area.
- Parameters:
- {function} callback
SetMouseLeftDownCallback(callback)
Set a callback to a MouseLeftButtonDown event in the DocumentViewer's viewing area.
- Parameters:
- {function} callback
SetMouseLeftUpCallback(callback)
Set a callback to a MouseLeftButtonUp event in the DocumentViewer's viewing area.
- Parameters:
- {function} callback
SetMouseMoveCallback(callback)
Set a callback to a MouseLeave event in the DocumentViewer's viewing area.
- Parameters:
- {function} callback
SetMouseRightDownCallback(callback)
Set a callback to a MouseRightButtonDown event in the DocumentViewer's viewing area.
- Parameters:
- {function} callback
SetMouseRightUpCallback(callback)
Set a callback to a MouseRightButtonUp event in the DocumentViewer's viewing area.
- Parameters:
- {function} callback
SetPageCompleteCallback(callback)
Sets the callback called when a page has been completely rendered.
- Parameters:
- {function} callback
SetPageNumberUpdatedCallback(callback)
Sets the function to call after the page number has been updated.
- Parameters:
- {function} callback
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.
SetPermissionCheckCallback(callback)
Sets the callback to perform the permision checking for annotations
- Parameters:
- {function} callback
SetRotation(pageRotation)
Sets the current viewing rotation.
- Parameters:
- {CoreControls.PageRotation} pageRotation
- desired viewing rotation.
SetTextSelectedCallback(callback)
Sets the function to call after text selection has been changed.
- Parameters:
- {function} callback
SetToolMode(toolMode)
Sets the tool mode. Also removes selection caused by text selection or search.
- Parameters:
- {DocumentViewer.ToolModes} toolMode
SetToolModeUpdatedCallback(callback)
Sets the function to call after the tool mode has been updated.
- Parameters:
- {function} callback
SetZoomUpdatedCallback(callback)
Sets the function to call after zoom has been updated.
- Parameters:
- {function} callback
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.
UpdateView(visiblePages, currentPageIndex)
Removes previously drawn pages that are no longer visible anddraws 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.
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.