-
<protected> new PccViewer()
-
This is the constructor for the PccViewer interaction object. An instance of this object is created when initializing the viewer, to allow programmatic interactions.
- See:
Example
$(document).ready(function () { //the PccViewer object is initialized through the jQuery plugin ('pccViewer') var viewer = $('#viewer').pccViewer({ //the viewingSessionId is generated by the server documentID: viewingSessionId, viewerType: 'pageView', imageHandlerUrl: '../pcc.ashx' }); //`viewer` is an instance of the PccViewer object, associated with the embedded viewer in #viewer });
Members
-
<static, readonly> pageCount :number
-
An ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8. It gives the number of pages in a document.
Type:
- number
- See:
-
- PCCViewer.PccViewer.getPageCount for more details.
-
<static> pageNumber :number
-
An ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8. Gets or Sets the current page of the viewer to the specified page number provided in the parameter. Setting the page number to a value other than the current page number will cause the viewer to navigate to the page number provided in the parameter.
Type:
- number
- See:
-
- PCCViewer.PccViewer.getPageNumber and {@link PCCViewer.PccViewer.setPageNumber} for more details.
Methods
-
changeToFirstPage() → {PccViewer}
-
Sets the current page of the viewer to the first page of the document. Note: Does nothing if the current page is the first page of the document.
Returns:
The PccViewer object.- Type
- PccViewer
Example
viewer.changeToFirstPage();
-
changeToLastPage() → {PccViewer}
-
Sets the current page of the viewer to the last known page of the document. Note: Does nothing if the current page is the last known page of the document.
Returns:
The PccViewer object.- Type
- PccViewer
Example
viewer.changeToLastPage();
-
changeToNextPage() → {PccViewer}
-
Sets the current page of the viewer to the next page of the document. Note: Does nothing if the current page is the last known page of the document.
Returns:
The PccViewer object.- Type
- PccViewer
Example
viewer.changeToNextPage();
-
changeToPrevPage() → {PccViewer}
-
Sets the current page of the viewer to the previous page of the document.
Returns:
The PccViewer object.- Type
- PccViewer
Example
viewer.changeToPrevPage();
-
fitPage(fitType)
-
Changes the presentation of the image to one of several pre-defined values.
Parameters:
Name Type Description fitType
string - See:
-
- PCCViewer.FitType for description of valid FitTypes.
Example
viewer.fitPage("FullImage"); //chained example viewer.rotatePage(180).fitPage("FullImage"); //example using FitType enumeration viewer.rotatePage(90).fitPage(PCCViewer.FitType.FullImage);
-
getPageCount() → {number}
-
Gets the page count of the current document.
- See:
-
- PCCViewer.EventType for the event type "PageCountReady".
Returns:
The page count. This value will be 1 before the viewer has the estimated or actual page count for the current document.- Type
- number
Example
// first create pccViewer var viewer = $("#viewer").pccViewer({documentID: viewingSessionId, viewerType: 'pageView', imageHandlerUrl: "../pcc.ashx") }); function pageCountReadyHandler(event) { var pageCount = viewer.getPageCount(); alert("Number of pages = " + pageCount); //now unsubscribe the event viewer.off("PageCountReady", pageCountReadyHandler); } // Subscribe to pageCountReady event exposed by the API viewer.on("PageCountReady", pageCountReadyHandler);
-
getPageNumber() → {number}
-
Gets the current page of the viewer. This method will will always return the value of the current page.
Returns:
The current page the viewer is on. This is a 1-based value, so the first page of a document is returned 1. Note: a value of 1 is returned before page count is available. PCCViewer.EventType.PageCountReady event.- Type
- number
Example
//Note: viewer was previously created var currentPageNumber = viewer.getPageNumber();
-
off(eventType, handler) → {PccViewer}
-
Unsubscribe from an event.
Typically, event is unsubscribed when you no longer want further notification of the event.
Parameters:
Name Type Description eventType
string A string specifying the event type. This value is case-insensitive. handler
function A function that was attached previously to the pccViewer - See:
-
- PCCViewer.PccViewer.on
Returns:
The PccViewer object.- Type
- PccViewer
Example
function handler(event) { alert("Hey PageCountReady was fired"); // UnSubscribe event that was previously subscribed to viewer.off("PageCountReady",handler); } // Subscribe to viewer events exposed by the API viewer.on("PageCountReady", handler);
-
on(eventType, handler) → {PccViewer}
-
Subscribe to an event.
Parameters:
Name Type Description eventType
string A string that specifies the event type. This value is case-insensitive. -
Supported Lifecycle event types
- “PageCountReady” - PCCViewer.EventType.PageCountReady
- “EstimatedPageCountReady” - PCCViewer.EventType.EstimatedPageCountReady
- “PageChanged” - PCCViewer.EventType.PageChanged
- “PageLoadFailed” - PCCViewer.EventType.PageLoadFailed
- “PageDisplayed” - PCCViewer.EventType.PageDisplayed
-
Supported User Action event types
- “PageRotated” - PCCViewer.EventType.PageRotated
- “ScaleChanged” - PCCViewer.EventType.ScaleChanged
- “WindowModeChanged” - PCCViewer.EventType.WindowModeChanged
- “DocumentPrinted” - PCCViewer.EventType.DocumentPrinted
- “TextSelected” - PCCViewer.EventType.TextSelected
- “MouseToolChanged” - PCCViewer.EventType.MouseToolChanged
handler
function A function that will be called whenever the event is fired.
Returns:
The PccViewer object.- Type
- PccViewer
Example
//create pccViewer var viewer = $("#viewer").pccViewer({documentID: viewingSessionId, viewerType: 'pageView', imageHandlerUrl: "../pcc.ashx", // Disable the built-in navigation bar of the viewer. uiElements: {navigation: false} }); function handler(event) { alert("Hey PageCountReady was fired, pageCount is = " + event.pageCount); } // Subscribe to viewer events exposed by the API viewer.on("PageCountReady", handler);
-
-
rotatePage(degreesClockwise) → {PccViewer}
-
Rotates the displayed page by the specified degrees clockwise, relative to the displayed page’s orientation. Throws if the value of degreesClockwise is not valid.
Parameters:
Name Type Description degreesClockwise
number Degrees clockwise to rotate the page. Valid values are: 90, 180, 270, -90, -180, or -270. Note: This method will use the modulo/modulus 360 value of the parameter (rotationAngle = param % 360). Throws:
-
If value of degreesClockwise is not valid. The Error object will contain property, 'message' with details of the error.
-
- Type
- Error
Returns:
The PccViewer object.- Type
- PccViewer
Example
try{ viewer.rotatePage(rotationAngle); } catch(e) { alert(".rotatePage() threw an error, rotationAngle = : " rotationAngle + "Error = " + e.message); }
-
-
setPageNumber() → {PccViewer}
-
A call to this method causes the viewer to navigate to the page, thereby setting the current page of the document to the specified page number in the document if the current page is different than the value being set. There is no action if the current page is the same as the value being set.
Parameters:
Name Type Description pageNumber.
number Note: A string representation of a valid number is also accepted as a parameter.. Throws:
-
If the parameter 'pageNumber' is out of range. A standard JavaScript error object will contain a 'message' property with details of the error.
-
- Type
- Error
Returns:
The PccViewer object.- Type
- PccViewer
Example
// first create the pccViewer : Note: if the viewer object has already been created, do not re-create it. var viewer = $("#viewer").pccViewer({documentID: viewingSessionId, viewerType: 'pageView', imageHandlerUrl: "../pcc.ashx") }); var pageNumberSet = 2; //define the handler function pageChangedHandler(event) { //get the current page number var pageNumber = viewer.getPageNumber(); //if current page number matches with the value we had set, then we know that the page has navigated. if(pageNumber === pageNumberSet) { //now unsubscribe the event Note: do not unsubscribe if future notifications are required. viewer.off("PageChanged", pageChangedHandler); alert("Viewer was navigated to the desired page successfully"); } else { alert("page has not yet navigated to the desired page"); } } // Subscribe to PageChanged event exposed by the API viewer.on("PageChanged", pageChangedHandler); try{ //set the page number to the desired number. We have set the number in the variable 'pageNumberSet' viewer.setPageNumber(pageNumberSet) } catch(exception) { //handle this error to suit your own application alert("set_pageNumber() caused an error, error message: " + exception.message); } }
-
-
zoomIn(zoomFactor) → {PccViewer}
-
This instructs the viewer to zoom in on the displayed page by the specified zoomFactor. For example, the call viewer.zoomIn(2), means zoom in by a factor of 2x, doubling the width and height of content. Note: the zoom factor is relative to the current zoom.
Parameters:
Name Type Description zoomFactor
number amount to zoom in. Valid values are in the interval [1.01, 20] Throws:
Invalid zoom factor value will cause the function to throw. The error object will contain message property with error details.Returns:
The PccViewer object.- Type
- PccViewer
Example
viewer.zoomIn(1.5); //Note you can also chain these methods viewer.rotatePage(90).zoomIn(2.0);
-
zoomOut(zoomFactor) → {PccViewer}
-
This instructs the viewer to zoom out on the displayed page by the specified zoomFactor. For example, the call viewer.zoomOut(2), means zoom out by a factor of 2x, halving the width and height of content.
Parameters:
Name Type Description zoomFactor
number Valid values are in the interval [1.01, 20]. Throws:
Invalid zoom factor values will cause the function to throw. The error object will contain message property with error detailsReturns:
The PccViewer object.- Type
- PccViewer
Example
viewer.zoomOut(2.0);