Class CoreControls.Document
Represents a document.
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 Attributes | Method Name and Description |
---|---|
CancelLoadCanvas(id)
Cancels the LoadCanvasAsync call corresponding to the passed in id
|
|
Cancels a download for offline mode in progress.
|
|
CancelThumbnailRequest(pageIndex, name)
Cancels the request made for the specified page's thumbnail.
|
|
Returns an array containing the bookmarks 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 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.
|
|
GetXODCoordinates(pageIndex, x, y)
Returns an object with 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.
|
|
Whether the document has already been downloaded for offline mode or not.
|
|
LoadAsync(partRetriever, callback)
Initialize a Document so that it can be used to load page canvases.
|
|
LoadCanvasAsync(pageIndex, zoom, pageRotation, drawComplete(canvases,pageIndex), drawProgressive, canvasNum)
Loads a canvas for a particular page index.
|
|
LoadPageText(pageIndex, onComplete(text))
Gets all the text on the requested page.
|
|
LoadThumbnailAsync(pageNumber, onLoadThumbnail(HTMLImageElement|HTMLCanvasElement), name)
Loads a thumbnail image for a particular page.
|
|
PauseLoadCanvas(id)
Pauses the LoadCanvasAsync call corresponding to the passed in id
|
|
ResumeLoadCanvas(id)
Resumes the LoadCanvasAsync call corresponding to the passed in id
|
|
SetOfflineModeEnabled(enabled)
Sets whether offline mode is enabled or not.
|
|
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.
CancelOfflineModeDownload()
Cancels a download for offline mode in progress. If there is no current download then this does nothing.
CancelThumbnailRequest(pageIndex, name)
Cancels the request made for the specified page's thumbnail.
- Parameters:
- pageIndex
- The page of the thumbnail to cancel its request
- name
- The name that was used in the LoadThumbnailAsync call. Different names are only required if requests for the same page will be occurring from multiple sources.
{array}
GetBookmarks()
Returns an array containing the bookmarks in the document.
- Returns:
- {array} An array containing the bookmarks in the current 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 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}
GetXODCoordinates(pageIndex, x, y)
Returns an object with 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.
IsDownloaded()
Whether the document has already been downloaded for offline mode or not.
LoadAsync(partRetriever, callback)
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.
{number}
LoadCanvasAsync(pageIndex, zoom, pageRotation, drawComplete(canvases,pageIndex), drawProgressive, canvasNum)
Loads a canvas for a particular page index.
- Parameters:
- {number} pageIndex
- The page number, zero-indexed, of the requested canvas.
- {number} zoom
- The zoom value to render the page at.
- {pageRotation} pageRotation
- 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} drawComplete(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} drawProgressive
- The callback to call when the canvas has been partially rendered.
- {number} canvasNum
- 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
LoadThumbnailAsync(pageNumber, onLoadThumbnail(HTMLImageElement|HTMLCanvasElement), name)
Loads a thumbnail image for a particular page.
- Parameters:
- {string} pageNumber
- The page number of the requested thumbnail.
- {function} onLoadThumbnail(HTMLImageElement|HTMLCanvasElement)
- The callback to call when the thumbnail has been retrieved.
- {string} name
- The name to associate with the thumbnail loading so that it can be cancelled It is passed an image element if the .xod file contains thumbnails and a canvas element otherwise.
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.
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.
SetOfflineModeEnabled(enabled)
Sets whether offline mode is enabled or not.
- Parameters:
- {boolean} enabled
- The new value for whether offline mode is enabled or not.
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.