本文介绍了如何从PDF.js iframe获取当前的PDF页码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将查看器托管在本地Web服务器上,并且iframe指向并加载了pdf.

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

然后我想按一个将页码记录"到文本文件中的按钮,我读到问题和答案,似乎暗示您可以使用pdf.getPage获取页码,但是当从iframe内部运行PDFJS时,如何访问PDFJS?

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?

谢谢.

推荐答案

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

这将访问iframe,然后在viewer.html中搜索包含页码的元素.现在需要做的就是将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.

这篇关于如何从PDF.js iframe获取当前的PDF页码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 21:18