Class Index

Classes


Class CoreControls.Document

Represents a document.

Class Summary
Constructor Attributes Constructor Name and Description
 
Constructs a new empty Document, representing a document with individual pages (canvases) that can be displayed on screen and printed.
Method Summary
Method Attributes Method Name and Description
 
Cancels the loadCanvasAsync call corresponding to the passed in id
 
Cancels the request made for thumbnail with the specified request Id
 
Cancels a download for offline mode in progress.
 
cropPages(pageArray, topMargin, botMargin, leftMargin, rightMargin)
Crop the given pages by the given margins
 
[PDF Document only] Get the updated context of a document
 
extractXFDF(pages)
Gets the XFDF data for the document's internal annotations.
 
Returns an array containing the bookmarks in the document.
 
[PDF Document only] Get an array describing the layers/OCG structure in the document.
 
getLinks(pageIndex)
Returns an array containing the links on the specified page of the document.
 
Returns whether offline mode is currently enabled or not.
 
Returns the number of pages in a document.
 
getPageInfo(pageIndex)
Returns an object containing the width and height of a page.
 
getPDFCoordinates(pageIndex, x, y)
Returns an object with the original x and y coordinates converted to PDF coordinates for the page.
 
getTextPosition(pageIndex, textStartIndex, textEndIndex, onComplete(quads))
Gets quads for each of the characters from start to end index.
 
getViewerCoordinates(pageIndex, x, y)
Returns an object with the original x and y PDF coordinates converted to Viewer coordinates for the page.
 
getXODCoordinates(pageIndex, x, y)
Returns an object with the original x and y PDF coordinates converted to XOD coordinates for the page.
 
Used to know if a document contains thumbnails.
 
initOfflineDB(onComplete)
Initializes the offline database for use.
 
insertBlankPages(insertBeforeThesePages, width, height)
Inserts blank pages before the given list of pages.
 
insertPages(sourceDocument, pageArray, insertBeforeThisPage)
[PDF Document only] Inserts a set of pages from the provided Document before a given page number.
 
Whether the document has already been downloaded for offline mode or not.
 
loadAsync(partRetriever, callback, options)
Initialize a Document so that it can be used to load page canvases.
 
loadCanvasAsync(options)
Loads a canvas for a particular page index.
 
loadPageText(pageIndex, onComplete(text))
Gets all the text on the requested page.
 
loadThumbnailAsync(pageIndex, onLoadThumbnail(HTMLImageElement|HTMLCanvasElement))
Loads a thumbnail image for a particular page.
 
movePages(pageArray, insertBeforeThisPage)
[PDF Document only] Moves the pages given in an array so they appear in sequence before a given page number
 
Pauses the loadCanvasAsync call corresponding to the passed in id
 
Refresh the text data stored by the viewer.
 
removePages(pageArray)
[PDF Document only] Removes the given page numbers.
 
Resumes the loadCanvasAsync call corresponding to the passed in id
 
rotatePages(pageArray, rotation)
Adds the given rotation to the given pages.
 
setLayersArray(layerContext)
[PDF Document only] Update the array describing the layers/OCG structure in order to adjust which layers should be enabled or disabled.
 
Sets whether offline mode is enabled or not.
 
[PDF Document only] Set the overprint preview mode to be used when rendering this document.
 
storeOffline(onComplete, onProgress)
Downloads the document for offline viewing.
 
Unloads resources for the page associated with the loadCanvasAsync call corresponding to the passed in id.
 
Cleans up the resources associated with the document.
Class Detail
CoreControls.Document(id)
Constructs a new empty Document, representing a document with individual pages (canvases) that can be displayed on screen and printed.
Parameters:
{string} id Optional
An optional unique identifier for the document to be used with offline mode
Method Detail
cancelLoadCanvas(id)
Cancels the loadCanvasAsync call corresponding to the passed in id
Parameters:
{number} id
The id returned from the loadCanvasAsync call that will be cancelled.

cancelLoadThumbnail(requestId)
Cancels the request made for thumbnail with the specified request Id
Parameters:
{number} requestId
The id returned from loadThumbnailAsync

cancelOfflineModeDownload()
Cancels a download for offline mode in progress. If there is no current download then this does nothing.

{Promise} cropPages(pageArray, topMargin, botMargin, leftMargin, rightMargin)
Crop the given pages by the given margins
Parameters:
pageArray
{[number]} an array of page numbers to crop
topMargin
{number} how much to crop from the top
botMargin
{number} how much to crop from the bottom
leftMargin
{number} how much to crop from the left
rightMargin
{number} how much to crop from the right
Returns:
{Promise} a promise that resolves to an object describing the cropped pages' new dimensions

{Promise} extractPDFNetLayersContext(layers)
[PDF Document only] Get the updated context of a document
Parameters:
layers
{[***]} layers
Returns:
{Promise} a promise that resolves to an array of the page numbers removed

{Promise} extractXFDF(pages)
Gets the XFDF data for the document's internal annotations.
Parameters:
{array} pages
An array of page numbers to get the XFDF data for
Returns:
{Promise} a promise the resolves to an object with an xfdfString property

{array} getBookmarks()
Returns an array containing the bookmarks in the document.
Returns:
{array} An array containing the bookmarks in the current document.

getLayersArray()
[PDF Document only] Get an array describing the layers/OCG structure in the document. Each entry in the array is a layer entry the form {obj: string, visible: boolean, name: titleString, children: [layerEntry1, layerEntry2...]}. The children entry contains an array which may contain additional layer entries. Both the obj and visible are optional. See the layers sample for an example of how to use getLayersArray and setLayersArray.
Returns:
A promise that resolves to an array representing the layers in the PDF document

{array} getLinks(pageIndex)
Returns an array containing the links on the specified page of the document.
Parameters:
{number} pageIndex
The page number, zero-indexed, that the links are on.
Returns:
{array} An array containing the links on the specified page of the document.

getOfflineModeEnabled()
Returns whether offline mode is currently enabled or not.

{number} getPageCount()
Returns the number of pages in a document.
Returns:
{number} The number of the pages in the current document.

{object} getPageInfo(pageIndex)
Returns an object containing the width and height of a page.
Parameters:
{number} pageIndex
The page number, zero-indexed, of the requested page.
Returns:
{object} An object representing the page info. Contains the properties "width" and "height".

{object} getPDFCoordinates(pageIndex, x, y)
Returns an object with the original x and y coordinates converted to PDF coordinates for the page.
Parameters:
{number} pageIndex
The page number, zero-indexed, that the coordinates are on
{number} x
The x coordinate
{number} y
The y coordinate
Returns:
{object} An object with the x and y PDF coordinates

getTextPosition(pageIndex, textStartIndex, textEndIndex, onComplete(quads))
Gets quads for each of the characters from start to end index.
Parameters:
{number} pageIndex
The page number, zero-indexed, that the text is on.
{number} textStartIndex
The position where to start getting character quads from.
{number} textEndIndex
The position (up to, but not including) where to finish getting characters.
{function} onComplete(quads)
The callback to call when the text positions are ready. quads is an array of objects with (x1,y1,x2,y2,x3,y3,x4,y4)

{object} getViewerCoordinates(pageIndex, x, y)
Returns an object with the original x and y PDF coordinates converted to Viewer coordinates for the page.
Parameters:
{number} pageIndex
The page number, zero-indexed, that the coordinates are on
{number} x
The x coordinate
{number} y
The y coordinate
Returns:
{object} An object with the x and y Viewer coordinates

{object} getXODCoordinates(pageIndex, x, y)
Returns an object with the original x and y PDF coordinates converted to XOD coordinates for the page.
Parameters:
{number} pageIndex
The page number, zero-indexed, that the coordinates are on
{number} x
The x coordinate
{number} y
The y coordinate
Returns:
{object} An object with the x and y XOD coordinates

{boolean} includesThumbnails()
Used to know if a document contains thumbnails.
Returns:
{boolean} True if the document contains thumbnails.

initOfflineDB(onComplete)
Initializes the offline database for use. Must be called before any other offline mode functions are used.
Parameters:
{function} onComplete
The function that's called when the offline database is ready for use.

{Promise} insertBlankPages(insertBeforeThesePages, width, height)
Inserts blank pages before the given list of pages.
Parameters:
insertBeforeThesePages
{[number]} array of page numbers before which to insert blanks
width
{number} width of the blank pages to insert
height
{number} height of the blank pages to insert
Returns:
{Promise} a promise that resolves to an object with info for any pages inserted

{Promise} insertPages(sourceDocument, pageArray, insertBeforeThisPage)
[PDF Document only] Inserts a set of pages from the provided Document before a given page number.
Parameters:
sourceDocument
{Document} other document from which to take pages (cannot be the same document)
pageArray
{[number]} array of page numbers to extract from the given document
insertBeforeThisPage
{number} page number before which to insert the pages
Returns:
{Promise} a promise the resolves to an object describing the inserted pages

isDownloaded()
Whether the document has already been downloaded for offline mode or not.

loadAsync(partRetriever, callback, options)
Initialize a Document so that it can be used to load page canvases.
Parameters:
{CoreControls.PartRetrievers.PartRetriever} partRetriever
An instance of PartRetriever.
{function(?Error)} callback
The callback to call when the Document has been initialized.
options
an object that can contain the following optional parameters
{Promise} options.workerTransportPromise Optional
Required for PDF viewing. A promise that will be resolved when a worker transport has been initialized. This can be created by calling CoreControls.initializeWorkerTransport
{function} options.getPassword Optional
An method of the form function(callback) where callback is of the form function(password). getPassword will be called when a password is required to load a PDF document and should call the callback with the retrieved password.
{string} options.extension Optional
An field used to specify the type of file being read. This is only relevant for PDF viewing and at the moment only works for certain image formats and .pdf

{number} loadCanvasAsync(options)
Loads a canvas for a particular page index.
Parameters:
{Object} options
An object specifying the options for loading the canvas. The following parameters should be properties on this object. The only non-optional parameter is pageIndex.
{number} options.pageIndex
The page number, zero-indexed, of the requested canvas.
{number} options.zoom Optional
The zoom value to render the page at.
{function} options.getZoom Optional
A function that returns the zoom value to render the page at. Use this instead of "zoom" if the value might change in the process of setting up the canvas.
{CoreControls.PageRotation} options.pageRotation Optional
The rotation of the page. Valid values are CoreControls.PageRotation.e_0, CoreControls.PageRotation.e_90, CoreControls.PageRotation.e_180, CoreControls.PageRotation.e_270.
{function} options.getPageRotation Optional
A function that returns the rotation of the page. Use this instead of "pageRotation" if the value might change in the process of setting up the canvas.
{function} options.finishedLoading Optional
A callback called after the list of page resources is retrieved. Return true if rendering should continue, false otherwise.
{function} options.acquireResources Optional
A function that returns whether resources need to be acquired or not, defaults to true.
{function} options.resourcesLoaded Optional
A callback called after the page's resources have been loaded. Return true if rendering should continue, false otherwise.
{function} options.getPageTransform Optional
A function that returns the x and y values of the page's translation.
{function} options.drawComplete Optional
(canvases,pageIndex) The callback to call when the canvas(es) have been completely rendered. It is passed an array of one or more canvases.
{function} options.drawProgressive Optional
The callback to call when the canvas has been partially rendered.
{number} options.canvasNum Optional
Force the page to be split into this many canvases
Returns:
{number} An id that can be passed to the corresponding Pause, Resume or Cancel functions

loadPageText(pageIndex, onComplete(text))
Gets all the text on the requested page.
Parameters:
{number} pageIndex
The page number, zero-indexed, that the text is on.
{function} onComplete(text)
The callback to call when the text is ready

{number} loadThumbnailAsync(pageIndex, onLoadThumbnail(HTMLImageElement|HTMLCanvasElement))
Loads a thumbnail image for a particular page.
Parameters:
{string} pageIndex
The page index of the requested thumbnail (0-indexed).
{function} onLoadThumbnail(HTMLImageElement|HTMLCanvasElement)
The callback to call when the thumbnail has been retrieved.
Returns:
{number} The id of the request that can later be used for cancelling the request It is passed an image element if the .xod file contains thumbnails and a canvas element otherwise.

{Promise} movePages(pageArray, insertBeforeThisPage)
[PDF Document only] Moves the pages given in an array so they appear in sequence before a given page number
Parameters:
pageArray
{[number]} the page numbers to move
insertBeforeThisPage
{number} page number before which to insert the other pages
Returns:
{Promise} a promise that resolves to an object describing the pages that were moved

pauseLoadCanvas(id)
Pauses the loadCanvasAsync call corresponding to the passed in id
Parameters:
{number} id
The id returned from the loadCanvasAsync call that will be paused.

refreshTextData()
Refresh the text data stored by the viewer. Useful if the text content of the document has changed, e.g. after a redaction.

{Promise} removePages(pageArray)
[PDF Document only] Removes the given page numbers.
Parameters:
pageArray
{[number]} the page numbers to remove
Returns:
{Promise} a promise that resolves to an array of the page numbers removed

resumeLoadCanvas(id)
Resumes the loadCanvasAsync call corresponding to the passed in id
Parameters:
{number} id
The id returned from the loadCanvasAsync call that will be resumed.

{Promise} rotatePages(pageArray, rotation)
Adds the given rotation to the given pages.
Parameters:
pageArray
{[number]} an array of the numbers of pages to rotate
rotation
{CoreControls.PageRotation} the page rotation to add
Returns:
{Promise} a promise that resolves to an object describing the newly rotated pages

setLayersArray(layerContext)
[PDF Document only] Update the array describing the layers/OCG structure in order to adjust which layers should be enabled or disabled.
Parameters:
layerContext
See:
getLayersArray

setOfflineModeEnabled(enabled)
Sets whether offline mode is enabled or not.
Parameters:
{boolean} enabled
The new value for whether offline mode is enabled or not.

setOverprintPreviewMode(mode)
[PDF Document only] Set the overprint preview mode to be used when rendering this document.
Parameters:
mode
The mode to use. Possible values are CoreControls.OverprintPreviewMode.OFF, CoreControls.OverprintPreviewMode.ON and CoreControls.OverprintPreviewMode.PDFX_ON

storeOffline(onComplete, onProgress)
Downloads the document for offline viewing.
Parameters:
{function} onComplete
The function that's called when the document has finished being downloaded or the download has been cancelled
{function(number)} onProgress
The function that's called on each update in progress of the download. The fraction downloaded is passed as a parameter. (eg 50% downloaded passes 0.5)

unloadCanvasResources(id)
Unloads resources for the page associated with the loadCanvasAsync call corresponding to the passed in id. So if the loadCanvasAsync call had requested page 2 then page 2's resources will be cleaned up (as long as nothing else requires those resources). Note that the canvas element itself is not touched.
Parameters:
{number} id
The id returned from the loadCanvasAsync call that will have it's page resources unloaded

unloadResources()
Cleans up the resources associated with the document.

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Sep 09 2016 14:32:37 GMT-0700 (PDT)