Some test text!

Legacy UI APIs

In this document
chevron_rightgetCurrentPageNumber()
chevron_rightgetFitMode()
chevron_rightgetInstance()
chevron_rightgetLayoutMode()
chevron_rightgetLayoutMode()
chevron_rightgetPageCount()
chevron_rightgetToolMode()
chevron_rightgetZoomLevel()
chevron_rightloadDocument(documentPath
chevron_rightrotateClockwise()
chevron_rightrotateCounterClockwise()
chevron_rightsetAdminUser(isAdmin)
chevron_rightsetAnnotationUser(username)
chevron_rightsetCurrentPageNumber(pageNumber)
chevron_rightsetFitMode(fitMode)
chevron_rightsetLayoutMode(layoutMode)
chevron_rightsetReadOnly(isReadOnly)
chevron_rightsetZoomLevel(zoomLevel)

This is a subset of APIs that are commonly used. For the full list, see PDFTron.WebViewer.

linkgetCurrentPageNumber()

Gets current page number (1-indexed).

Parameters

  • N/A

Returns

  • Page number (number)

Example

$(viewerElement).on('viewerLoaded', function() {
  console.log(myWebViewer.getCurrentPageNumber());
});

linkgetFitMode()

Return the current fit mode of the WebViewer.

Parameters

  • N/A

Returns

  • Fit mode (PDFTron.WebViewer.FitMode)

Example

$(viewerElement).on('ready', () => {
  console.log(myWebViewer.getFitMode());
});

linkgetInstance()

Return the instance of the ReaderControl object loaded by WebViewer.

Parameters

  • N/A

Returns

  • ReaderControl instance (object)

Example

$(viewerElement).on('ready', () => {
  console.log(myWebViewer.getInstance());
});

linkgetLayoutMode()

Return the current layout mode of the WebViewer.

Parameters

  • N/A

Returns

  • Layout mode (PDFTron.WebViewer.LayoutMode)

Example

$(viewerElement).on('ready', () => {
  console.log(myWebViewer.getLayoutMode());
});

linkgetLayoutMode()

Return the current layout mode of the WebViewer.

Parameters

  • N/A

Returns

  • Layout mode (PDFTron.WebViewer.LayoutMode)

Example

$(viewerElement).on('ready', () => {
  console.log(myWebViewer.getLayoutMode());
});

linkgetPageCount()

Return the total number of pages of the document loaded in the WebViewer.

Parameters

  • N/A

Returns

  • Total page number (number)

Example

$(viewerElement).on('ready', () => {
  console.log(myWebViewer.getPageCount());
});

linkgetToolMode()

Return the current tool.

Parameters

  • N/A

Returns

  • Tool mode object (PDFTron.WebViewer.ToolMode)

Example

$(viewerElement).on('ready', () => {
  console.log(myWebViewer.getToolMode());
});

linkgetZoomLevel()

Return the current zoom level

Parameters

  • N/A

Returns

  • Zoom level (number)

Example

$(viewerElement).on('ready', () => {
  console.log(myWebViewer.getZoomLevel());
});

linkloadDocument(documentPath[, options])

Load a document inside WebViewer UI.

Parameters

  • documentPath (string or fileObject) - Path to the document OR file object if opening local file.
  • options (object, optional) - Object with following parameters:

    • documentId (string) - Unique id of the document.
    • filename (string) - Filename of the document, which is used when downloading the PDF.
    • customHeaders (object) - An object custom HTTP headers to use when retrieving the document from the specified url. For example: {'Authorization' : 'Basic dXNlcm5hbWU6cGFzc3dvcmQ='}

Returns

  • N/A

Example

$(viewerElement).on('ready', () => {
  myWebViewer.loadDocument('/path/to/document.pdf', { documentId: '1', filename: 'sample-1' });
});

linkrotateClockwise()

Rotates the document in the WebViewer clockwise.

Parameters

  • N/A

Returns

  • N/A

Example

$(viewerElement).on('ready', () => {
  myWebViewer.rotateClockwise();
});

linkrotateCounterClockwise()

Rotates the document in the WebViewer counter-clockwise.

Parameters

  • N/A

Returns

  • N/A

Example

$(viewerElement).on('ready', () => {
  myWebViewer.rotateCounterClockwise();
});

linksetAdminUser(isAdmin)

Sets the current user to be admin or not. Admin users have permission to edit/delete any annotations, including the ones they didn't create.

Parameters

  • isAdmin (boolean) - Whether or not to set the current user to be an admin.

Returns

  • N/A

Example

// sets the current user to be an admin
$(viewerElement).on('ready', () => {
  myWebViewer.setAdminUser(true);
});

linksetAnnotationUser(username)

Sets name of the current user

Parameters

  • username (string) - Username to be used for current user.

Returns

  • N/A

Example

$(viewerElement).on('ready', () => {
  myWebViewer.setAnnotationUser('Guest-1');
});

linksetCurrentPageNumber(pageNumber)

Sets the current page number of the document loaded in the WebViewer.

Parameters

  • pageNumber (number) - The page number of the document to set

Returns

  • N/A

Example

$(viewerElement).on('ready', () => {
  myWebViewer.setCurrentPageNumber(1);
});

linksetFitMode(fitMode)

Sets the fit mode of the viewer.

Parameters

  • fitMode (PDFTron.WebViewer.FitMode)

    • PDFTron.WebViewer.FitMode.FitPage
    • PDFTron.WebViewer.FitMode.FitWidth
    • PDFTron.WebViewer.FitMode.Zoom

Returns

  • N/A

Example

$(viewerElement).on('ready', () => {
  myWebViewer.setFitMode(PDFTron.WebViewer.FitMode.FitPage);
});

linksetLayoutMode(layoutMode)

Sets the layout mode of the viewer.

Parameters

  • layoutMode (PDFTron.WebViewer.LayoutMode)

    • PDFTron.WebViewer.LayoutMode.Single
    • PDFTron.WebViewer.LayoutMode.Continuous
    • PDFTron.WebViewer.LayoutMode.Facing
    • PDFTron.WebViewer.LayoutMode.FacingContinuous
    • PDFTron.WebViewer.LayoutMode.FacingCover
    • PDFTron.WebViewer.LayoutMode.FacingCoverContinuous

Returns

  • N/A

Example

$(viewerElement).on('ready', () => {
  myWebViewer.setFitMode(PDFTron.WebViewer.FitMode.FitPage);
});

linksetReadOnly(isReadOnly)

Sets the WebViewer UI to be a read only mode. In read only mode, users cannot create/edit annotations.

Parameters

  • isReadOnly (boolean) - Whether or not to set the WebViewer UI to be in in read only mode.

Returns

  • N/A

Example

// sets the viewer to read only mode
$(viewerElement).on('ready', () => {
  myWebViewer.setReadOnly(true);
});

linksetZoomLevel(zoomLevel)

Sets zoom level.

Parameters

  • zoomLevel (number) - Zoom level in number.

Returns

  • N/A

Example

$(viewerElement).on('ready', () => {
  myWebViewer.setZoomLevel(1.5);
});