How can I get the current PDF page number from PDF.js iframe?

﹥>﹥吖頭↗ 提交于 2020-01-21 08:55:51

问题


I have the viewer hosted on my local webserver and the iframe points and loads up the pdf.

I then want to press a button that 'logs' the page number to a text file, I read this question and answer which seems to suggest you can use pdf.getPage to get the page number but how can i access the PDFJS when it is being ran from inside of the iframe?

Thank you.


回答1:


var iFrame =  document.getElementById('iframe_id');
if ( iFrame.contentDocument ) {
    currentPageNum= iFrame.contentDocument.getElementById('pageNumber').value;
}
alert(currentPageNum);

This will access the iframe and then search the viewer.html for the element that contains the page number. All that needs doing now is to pass currentPageNum to the form.



来源:https://stackoverflow.com/questions/35873181/how-can-i-get-the-current-pdf-page-number-from-pdf-js-iframe

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!