Is there a possible way to do a PDF page count in javascript (with titanium)? I'm working on an application, and i need the amount of pages to know on which page a user is. Right now i'm doing the amount of pages hard coded, but I want to retrieve the pages via javascript.
var pageheight;
var numPages = 180;
wv.addEventListener('load', function(e){
var documentHeight = wv.evalJS('window.outerHeight');
var innerHeight = wv.evalJS('window.innerHeight');
var ratio = innerHeight / wv.height;
pageHeight = parseInt(ratio * (documentHeight / numPages), 10);
Ti.API.info(title);
wv.evalJS("var currentPage = 1;");
wv.evalJS("window.onscroll = function() { currentPage = parseInt(window.pageYOffset/" + pageHeight + ") + 1;}");
wv.evalJS("window.onclick = function() { currentPage = parseInt(window.pageYOffset/" + pageHeight + ") + 1;}");
setInterval(getCurrentPage, 100);
});
function jumpToPage(page){
wv.evalJS('window.scrollTo(0, ' + pageHeight * (page - 1) + ');');
}
function getCurrentPage(){
var currentPage = parseInt(wv.evalJS("currentPage"), 10);
Ti.API.info('currentpage: ' + currentPage);
Ti.API.info(title)
}
I hope someone can help me, i really needs this to work.
thanks in advance