new DocumentController()
WebDocumentViewer Document operations API.
Methods
movePages(sourceIndices, destinationIndex, callbackopt)
Moves pages from the source indices to the destination index within single document.
Parameters:
Name | Type | Description |
---|---|---|
sourceIndices |
Array.<number> | Array.<string> | Source indices to get pages from. Can be passed as string representation of numbers |
destinationIndex |
number | string | Destination index to insert pages. Can be passed as string representation of a number |
[callback] |
NotificationCallback | Function to execute when the operation has completed. |
getBookmarks() → {Array.<BookmarkData>}
Gets all bookmarks for PDF document.
Returns:
- Type
- Array.<BookmarkData>
getPageReference(index) → {DocumentPageReference}
Gets the page reference object for the specified page. This can be passed as a 'srcindex' parameter into document.insertPage method.
Parameters:
Name | Type | Description |
---|---|---|
index |
number | Index of the page to get the reference. |
Returns:
getPageRotation(index) → {number}
Gets the rotation angle of the specified page.
Parameters:
Name | Type | Description |
---|---|---|
index |
number | Index of the page to retrieve rotation angle. |
Returns:
Clockwise rotation angle of the specified page.
- Type
- number
insertPage(documenturlopt, src, destination, callbackopt)
Inserts a page at the destination index from the given source uri and index.
Parameters:
Name | Type | Description |
---|---|---|
[documenturl] |
string | The identifier of the document which contains the page. If empty, |
src |
number | string | DocumentPageReference | zero based index of the page in the source document. Can be passed as string representation of a number. Or page descriptor returned by the |
destination |
number | Index in the target document to insert the page. |
[callback] |
NotificationCallback | function to execute when the operation has completed. |
Example
_thumb1.document.insertPage(null, _thumb2.document.getPageReference(0), 0);
// this call will insert new page and correctly handle annotations and forms data, so new empty layers will be created.
// If annotations should be also coped from the source document, it could be done explicitly using following code
var annotations = _thumb1.annotations.getFromPage(0);
for (var i = 0; i < annotations.length; i++) {
_thumb2.annotations.createOnPage(annotations[i], 0);
}
insertPages(documenturlopt, src, destination, callbackopt)
Inserts a page at the destination index from the given source uri and index.
Parameters:
Name | Type | Description |
---|---|---|
[documenturl] |
string | The identifier of the document which contains the page. If empty, |
src |
Array.<number> | Array.<string> | Array.<DocumentPageReference> | zero based indices of the pages in the source document. Can be passed as string representation of numbers. Or page descriptors returned by the |
destination |
number | Index in the target document to insert the page. |
[callback] |
NotificationCallback | function to execute when the operation has completed. |
movePage(sourceIndex, destinationIndex, callbackopt)
Moves a page from the source index to the destination index within single document.
Parameters:
Name | Type | Description |
---|---|---|
sourceIndex |
number | string | Source index to get the page from. Can be passed as string representation of a number |
destinationIndex |
number | string | Destination index to insert the page. Can be passed as string representation of a number |
[callback] |
NotificationCallback | Function to execute when the operation has completed. |
getChildBookmarks(bookmark) → {Array.<BookmarkData>}
Gets an array of child bookmarks relative to specified.
Parameters:
Name | Type | Description |
---|---|---|
bookmark |
BookmarkData | Bookmark object for which children are searched. |
Returns:
- Type
- Array.<BookmarkData>
removeAllBookmarks(callbackopt)
Removes whole information about the bookmarks from PDF document.
Parameters:
Name | Type | Description |
---|---|---|
[callback] |
NotificationCallback | Function to be called when the operation has completed. |
removePage(index, callbackopt)
Removes the page at the given index.
Parameters:
Name | Type | Description |
---|---|---|
index |
number | string | Index of the page to remove. Can be passed as string representation of a number |
[callback] |
NotificationCallback | Function to execute when the operation has completed. |
removePages(indices, callbackopt)
Removes pages at given indices.
Parameters:
Name | Type | Description |
---|---|---|
indices |
Array.<number> | Array.<string> | Indices of pages to remove. Can be passed as string representation of numbers |
[callback] |
NotificationCallback | Function to execute when the operation has completed. |
rotatePage(index, angle, callbackopt)
Rotates the specified angle page to the specified angle.
Note, that angle
represents final rotation value that will be applied to the original page. *
Parameters:
Name | Type | Description |
---|---|---|
index |
number | string | Index of the page to rotate. Can be passed as string representation of a number |
angle |
number | string | Clockwise rotation angle in degrees. Can be passed as string representation of a number |
[callback] |
NotificationCallback | Function to execute when the operation has completed. |
Example
viewer.document.rotatePage(0, viewer.document.getPageRotation(0) + 90);
rotatePages(indices, angles, callbackopt)
Rotates specified angle pages to specified angles.
Note, that angles
represents final rotation values that will be applied to original pages.
Parameters:
Name | Type | Description |
---|---|---|
indices |
Array.<number> | Array.<string> | Indices of pages to rotate. |
angles |
number | Array.<number> | string | Array.<string> | Clockwise rotation angles in degrees. Can be passed as string representation of a number If angles is a number|string or an number[]|string[] with length 1, then all pages will be rotated to this angle, otherwise each page will be rotated to the specified angle in array. |
[callback] |
NotificationCallback | Function to execute when the operation has completed. |
Examples
viewer.document.rotatePages([0, 3], 90)
viewer.document.rotatePages([0, 3], [180, 90])
scrollToBookmark(bookmark, callbackopt)
Scrolls viewer to the specified bookmark.
Parameters:
Name | Type | Description |
---|---|---|
bookmark |
BookmarkData | Bookmark object to scroll to. |
[callback] |
NotificationCallback | Function to be called when the operation has completed. |
Events
documentchanged
Triggers when the document is changed. This event indicates document structure or internal state changes and causes visible pages repaint.
pageinserted
Triggers when a page is added to the document.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
e |
Object | Event arguments. Properties
|
pagemoved
Triggers when a page is moved within the same document.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
e |
Object | Event arguments. Properties
|
pageremoved
Triggers when a page is removed from the document.
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
e |
Object | Event arguments. Properties
|
pagerotated
Fired when document page has been rotated.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
e |
Object | Event arguments Properties
|