Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

javascript - Get Current Page number of Embedded pdf

I am planning to develop a webapp. The page will have an iframe on the left side and javascript form on right side. The iframe will be used to view pdfs from server.

I have been looking for ways to capture or get the current page number of the pdf being viewed in the iframe.

Is this possible?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

One suggestion would be to try and use PDF.js, a PDF viewer that is built with HTML5. This might help you get around the need to use an iFrame to render the PDFs. But, if you need the iFrame for other reasons, then try looking at the PDF.js examples. As indicated on a previous stackoverflow thread, there are functions you could take advantage of:

PDFJS.getDocument('helloworld.pdf').then(function(pdf) {
    // you can now use *pdf* here

    pdf.getPage(1).then(function(page) {
            // you can now use *page* here
        });
}); 

Hope this helps the cause.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.6k users

...