最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Re-open pdf with pdf.js at the beginning of the document. Not last viewed position - Stack Overflow

programmeradmin4浏览0评论

The plugin saves the last position the document was in before it is closed and next time I open the document, it shows the document in this position.

Example:

I am seeing the middle of the second page. I close the document. I open it again and it opens in the middle of the second page.

I want to re-open it at the begginning.

Does anybody knows how to change that behavior?

The plugin saves the last position the document was in before it is closed and next time I open the document, it shows the document in this position.

Example:

I am seeing the middle of the second page. I close the document. I open it again and it opens in the middle of the second page.

I want to re-open it at the begginning.

Does anybody knows how to change that behavior?

Share Improve this question edited Jan 22, 2013 at 10:53 Vainglory07 5,29310 gold badges46 silver badges79 bronze badges asked Jan 15, 2013 at 15:11 Guilherme LongoGuilherme Longo 2,3087 gold badges47 silver badges65 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 6

You should be able to just add a bookmark to the URL, like a traditional HTML bookmark that follows a #. For example:

<iframe src="viewer.html?file=/sample.pdf#0"></iframe>

Or if you're loading the viewer directly in your browser, just append #0 to the URL. That should override any other bookmark your browser may be remembering, according to the following code in viewer.js:

initialBookmark: document.location.hash.substring(1),

I also had that preferred behavior and what I did was open the viewer.js and remove the initialBookmark variable and all references to it.

Bit dirty, but it did the trick and did not want to spend the entire day filtering through the different url variables that would be able to change the behavior ..

If you are using javascript, trigger this function to go to the first page,

$window.PDFViewerApplication.eventBus.dispatch('pagenumberchanged',{"value": 1}); 
发布评论

评论列表(0)

  1. 暂无评论