How can I get the current PDF page number from PDF

2019-05-19 05:36发布

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.

标签: iframe pdf.js
1条回答
Ridiculous、
2楼-- · 2019-05-19 05:44
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.

查看更多
登录 后发表回答