Can we display a text for current page '1 of 3' when viewing the XOD on mobile?

26 views
Skip to first unread message

Vinoth Kumar

unread,
Jun 8, 2016, 4:56:47 PM6/8/16
to PDFTron WebViewer
Hi,

We like to show the current page number along with the total page number like '1 of 3' when viewing a XOD file in mobile.

Is it possible to implement with some customization?

Thanks,
Vinoth

Matt Parizeau

unread,
Jun 9, 2016, 3:10:56 PM6/9/16
to PDFTron WebViewer
Hi Vinoth,

Yes this is possible. Here's some simple sample code to get you started:

var pageCountElement = $('<div></div>').css({
  background
: 'white',
  height
: 40,
  width
: 150,
  position
: 'absolute',
  top
: 50,
  left
: 50
});

$
('body').append(pageCountElement);

var docViewer;

$
(document).on('viewerLoaded', function() {
  docViewer
= readerControl.docViewer;
  docViewer
.on('pageNumberUpdated', function() {
    updateCount
();
 
});
});

$
(document).on('documentLoaded', function() {
  updateCount
();
});

function updateCount() {
 
var totalPages = docViewer.getPageCount();
 
var currentPage = docViewer.getCurrentPage();
  pageCountElement
.text(currentPage + ' of ' + totalPages);
}

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Vinoth Kumar

unread,
Jun 16, 2016, 12:56:07 PM6/16/16
to PDFTron WebViewer
Thanks Matt for the help. This is working perfectly fine.
Reply all
Reply to author
Forward
0 new messages