Skip to content
Guides

Page Navigation

After loading a PDF document, you can programmatically interact with it, which allows you to view and transition between the pages like scrolling and jumping to specific pages.

javascript
// Previous page.
docViewer.previousPage();

// Next page.
docViewer.nextPage();

// Jump to a page.
docViewer.pageNumberChanged('3');

If you want to receive notifications when page numbers change, you can listen for the onPageNumberUpdated' event.

Scroll

To scroll to specific distances in the horizontal and vertical directions, you can use the scrollTo function.

javascript
// Top and left are optional.
docViewer.scrollTo({
  top: 200,
  left: 100
});

To scroll a certain percentage of distance horizontally or vertically, you can use the scrollToPercent function.

javascript
// Top and left are optional.
docViewer.scrollToPercent({
  top: 20,
  left: 50
});

Scroll Mode

ComPDFKit for Web has two scrolling modes: Vertical and Horizontal. You can set the corresponding mode by using the following method.

javascript
docViewer.webViewerSwitchScrollMode(mode);

This is the parameters to apply different scroll modes.

NameRequiredTypeDescription
modeyesnumberScroll Mode Parameter, Vertical: 0, Horizontal: 1

Thumbnails

Provide methods to render PDF pages as thumbnail images.