how to open specific page on Google's docs viewer

后端 未结 5 526
刺人心
刺人心 2020-12-24 02:49

I\'m using google\'s docs viewer to show a pdf document in a html page and I would like to open the document starting on page 20 instead of 1 for example.

There\'s h

5条回答
  •  生来不讨喜
    2020-12-24 03:37

    My PDF is 13 pages, but when I used hash: 0.page.13, it only jumped to page 10. I had to setTimeout and call the same function again:

    Only needed to do that once per page load, then it seems to be synched properly. I am sure there is a more elegant solution:

    var is_caught_up = false;
    function pdf_go(page){
         $('pdf_frame').contentWindow.location.hash=':0.page.'+page;
         if (!is_caught_up){
             setTimeout('pdf_catchup('+page+')', 500);
         }
    }
    
    function pdf_catchup(page){
        $('pdf_frame').contentWindow.location.hash=':0.page.'+page;
         is_caught_up = true;
    }
    

提交回复
热议问题