Jumping pages/following links changes horizontal position

Bug #1442874 reported by Thomas Weidner
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
qpdfview
Fix Released
Low
Adam Reichold

Bug Description

Here is my scenario:
I open a PDF with pretty wide left/right page margins (LaTeX generated). So i zoom the page that the margins are not visible. Horizontal scrolling is set up to center the page. Two things now cause a bad usability:

1. Changing the page number either via the prev/next buttons or by entering a page number directly resets the horizontal scroll position to 0. Thus showing me the left page margin and the left part of the body text, forcing me to adjust horizontal scroll position again.

2. Clicking a link that points to a position within the PDF seems to try to center the linked position. Thus for example, clicking a link to an equation, which has the anchor quite on the right side of the body text, shows me the right margin and the right part of the body text.

Suggestion: Do not change horizontal scroll position when changing pages. When following links only change horizontal scroll position if the anchor is not visible without changing it.

Issues: What about documents which are not usual top->bottom text? Does page orientation matter?

Revision history for this message
Adam Reichold (adamreichold) wrote :

Hello Thomas,

thanks for taking the time to report this. I created the linked branch which tries to keep the page-relative positions when just jumping to a new page a no explicit new page-relative position is given. Could you build it from the sources and give it a try?

Jumping to a link does not center the link position, but rather some links (within PDF documents at least) contain explicit set-left-of-viewport and/or set-top-of-viewport information which we try to follow as best as we can w.r.t. the current view mode. So if your link to an equation moves the equation itself out of the viewport, then these hints maybe wrong. Could you provide an example file where this happens?

Best regards, Adam.

P.S.: Have you tried the "Trim margins" setting available in newer versions which will try to automatically remove empty margins so that one can for example use fit-to-width view modes more comfortably.

Changed in qpdfview:
status: New → In Progress
importance: Undecided → Low
assignee: nobody → Adam Reichold (adamreichold)
Revision history for this message
Thomas Weidner (thomas001le) wrote :

I tried your branch and following links now works much better. I did not find a case, where the viewport was badly positioned.

I attached a test PDF where clicking the link in the last line positions the viewport to the right, whereas the target of the link (the equation or the "(1)" in the equation) would be visible without changing horizontal scrolling.

Trim margins looks really nice, but has scrolling bugs of its own: When the PDF file is refreshed (because a new version is written by the latex compiler) the vertical scroll position changes slightly (like ~5 lines of text). So after a series of recompilations the area of interest eventually moves out of the viewport.

Revision history for this message
Adam Reichold (adamreichold) wrote : Re: [Bug 1442874] Re: Jumping pages/following links changes horizontal position

Hello,

Am 15.04.2015 um 11:36 schrieb Thomas Weidner:
> I tried your branch and following links now works much better. I did not
> find a case, where the viewport was badly positioned.

I will merge this into trunk when I find some spare time to do so then.

> I attached a test PDF where clicking the link in the last line positions
> the viewport to the right, whereas the target of the link (the equation
> or the "(1)" in the equation) would be visible without changing
> horizontal scrolling.

I tested the document and it seems to work as intended: The link
contains set-left-of-viewport 0.48 (relative to page with) and
set-top-of-viewport 0.35 (relative to page height) which positions the
top left of the viewport left and above of the equation itself, i.e.
right next to the a character.

So we are explicitly requested to adjust the horizontal and vertical
position by the link. Whether a link target that is centered on the page
is optimal is debatable, but this is up to the document itself.

We could of course opt to interpret that request as to only scroll if
this position is not already inside the viewport, but as this is pretty
intrusive and hence I added a setting called "scroll if not visible" to
the behaviour tab of the related branch. Please try give it a try as
well. Thanks!

> Trim margins looks really nice, but has scrolling bugs of its own: When
> the PDF file is refreshed (because a new version is written by the latex
> compiler) the vertical scroll position changes slightly (like ~5 lines
> of text). So after a series of recompilations the area of interest
> eventually moves out of the viewport.

This is caused by the page dimensions changing after the first render
pass, i.e. after the margins have been trimmed. When page-relative
positions w.r.t. the original size are then restored w.r.t. to the
trimmed size, the real position changes.

The problem actually goes deeper insofar all page-relative locations are
computed using the modified instead of the original bounding box. When I
merge the mentioned branch, I will try to replace all page-relative
position computations using the unmodified bounding box which should
hopefully resolve most of these issues...

Best regards, Adam.

> ** Attachment added: "test-eq.pdf"
> https://bugs.launchpad.net/qpdfview/+bug/1442874/+attachment/4376071/+files/test-eq.pdf
>

Revision history for this message
Adam Reichold (adamreichold) wrote :

The related branch should now also fix the jump-on-refresh problem
w.r.t. to trim-margins. Of course fixing this interacts badly with the
scroll-if-not-visible functions which needs some special casing for this
to work. (For now I only allow the view not to scroll, when I explicitly
jump to some position, e.g. by clicking a link.)

Testing is appreciated. Thanks!

Am 15.04.2015 um 11:36 schrieb Thomas Weidner:
> I tried your branch and following links now works much better. I did not
> find a case, where the viewport was badly positioned.
>
> I attached a test PDF where clicking the link in the last line positions
> the viewport to the right, whereas the target of the link (the equation
> or the "(1)" in the equation) would be visible without changing
> horizontal scrolling.
>
> Trim margins looks really nice, but has scrolling bugs of its own: When
> the PDF file is refreshed (because a new version is written by the latex
> compiler) the vertical scroll position changes slightly (like ~5 lines
> of text). So after a series of recompilations the area of interest
> eventually moves out of the viewport.
>
> ** Attachment added: "test-eq.pdf"
> https://bugs.launchpad.net/qpdfview/+bug/1442874/+attachment/4376071/+files/test-eq.pdf
>

Revision history for this message
Adam Reichold (adamreichold) wrote :

I merged the branch into trunk and fixed for usage with Qt4 so that it can receive more testing by a wider audience.

Changed in qpdfview:
milestone: none → 0.4.15
status: In Progress → Fix Committed
Changed in qpdfview:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.