Garrett
Garrett

Reputation: 4394

Vertically position an embedded PDF in browser by half page increment

It's possible to position a PDF onto a certain page by adding the fragment identifier

#page=N

to the URL (at least in Chromium and Firefox).

Is there any way to position by half pages? For example, something like: #page=1.5.

Upvotes: 0

Views: 46

Answers (2)

Script_Coded
Script_Coded

Reputation: 710

For doing scrolling, this should do it. It's a bit of jQuery. You could include your PDF with an iframe and and change ´$("body")´ to your iframe selector.

$(function() {
    var fragment = window.location.hash.split("=");
    if (fragment[0] == "#page") {
        $("body").scrollTop($(window).height() * fragment[1]);
    }
});

Upvotes: 1

Mark Redman
Mark Redman

Reputation: 24515

For displaying PDF files in the browser, it may be easier to convert/rasterise the file to an image then just display part of the image required. This way you have much more control of the image rather than trying to manipulate the PDF (plugin or other PDF rendering).

Upvotes: 1

Related Questions