Bug 102698 - PDF bookmarks off by one
Summary: PDF bookmarks off by one
Status: RESOLVED NOTOURBUG
Alias: None
Product: poppler
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-13 08:49 UTC by Tristan Miller
Modified: 2017-09-13 13:04 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Sample file showing bookmark bug (14.56 KB, application/x-download)
2017-09-13 08:49 UTC, Tristan Miller
Details

Description Tristan Miller 2017-09-13 08:49:23 UTC
Created attachment 134194 [details]
Sample file showing bookmark bug

In some PDF documents (in particular, those produced with the LaTeX Powerdot class using a certain page size), the internal page bookmarks are all off by one.  Take the attached document test.pdf as an example.  Regardless whether you use the document's own hyperlinks in the left-hand column of the page, or the PDF table of contents exposed by the PDF viewer, clicking on "A" takes you to slide "B", "B" takes you to slide "C", and "C" takes you to slide "D".

This problem occurs only when viewing the document with Poppler-based viewers, such as Okular and Evince.  Readers such as Adobe Acrobat Reader DC are not affected.


Reproducible: Always

Steps to Reproduce:
1. Open the attached document test.pdf and click on the "A", "B", or "C" links in the left-hand column of the page or in Okular's table of contents.

Actual Results:  
2. Clicking on "A" takes you to slide "B", "B" takes you to slide "C", and "C" takes you to slide "D".

Expected Results:  
2. Clicking on "A" should take you to slide "A", "B" to slide "B", and "C" to slide "C".


The document was created using an up-to-date TeX Live 2017 system and Ghostscript 9.21's ps2pdf:

$ cat >test.tex
\documentclass[paper=smartboard]{powerdot}
\listfiles
\begin{document}
\begin{slide}{A}\end{slide}
\begin{slide}{B}\end{slide}
\begin{slide}{C}\end{slide}
\begin{slide}{D}\end{slide}
\end{document}

$ latex test;latex test;dvips test;ps2pdf test.ps
$ okular test.pdf

The problem may have something to do with the page size. The problem does not occur when "smartboard" is changed to "screen", "a4paper", or "letterpaper".  Looking at the Powerdot source code, it doesn't seem that Powerdot itself uses the page size to determine how the bookmarks are set.

Downstream report: https://bugs.kde.org/show_bug.cgi?id=370949
Comment 1 Adrian Johnson 2017-09-13 11:01:54 UTC
Works fine for me with evince. If you turn off continuous mode it will select the right page. If you turn on continuous mode it will appear to select the wrong page. The reason is:

pdfinfo -dests test.pdf
Page  Destination                 Name
   1 [ XYZ   -0   31 null      ] "Doc-Start"
   1 [ XYZ   -0    9 null      ] "slide.1"
   2 [ XYZ   -0    9 null      ] "slide.2"
   3 [ XYZ   -0    9 null      ] "slide.3"
   4 [ XYZ   -0    9 null      ] "slide.4"

According to PDF32000 Table 151 the "XYZ" destination means:

[page /XYZ left top zoom]
"Display the page designated by page, with the coordinates (left, top)
positioned at the upper-left corner of the window and the contents of
the page magnified by the factor zoom. A null value for any of the
parameters left, top, or zoom specifies that the current value of that
parameter shall be retained unchanged. A zoom value of 0 has the
same meaning as a null value."

The above output shows left = 0 and top = 9 or 31. (0,0) is the bottom left of the page. So left = 0, top = 9 is a point 0" from the left and 9/72" from the bottom. When this point is positioned "at the upper-left corner of the window" in continuous mode, almost all of the selected page is above the top of the window and the next page will be visible.

If you want the selected page entirely visible you should specify a point at the top of the page or use one of the other destination options.

The problems seems to be with the ps2pdf conversion. Looking at test.ps the dests are:

SDict begin [/Count 0/Dest (slide.1) cvn/View [/XYZ null null null]/Title
(A) /OUT pdfmark end
 -600 6689 a -600 6689 a
SDict begin [/Count 0/Dest (slide.2) cvn/View [/XYZ null null null]/Title
(B) /OUT pdfmark end
 -600 6689 a -600
6689 a
SDict begin [/Count 0/Dest (slide.3) cvn/View [/XYZ null null null]/Title
(C) /OUT pdfmark end
 -600 6689 a -600 6689 a
SDict begin [/Count 0/Dest (slide.4) cvn/View [/XYZ null null null]/Title
(D) /OUT pdfmark end
 -600 6689 a -600 6689

ie the left, top is "null null". Which means "unchanged". But after conversion to pdf the dest of the first bookmark is

"<</D [4 0 R /XYZ -0.269996643 8.50524902 null]>>endobj"

ie left = 0.26, top = 8.5 which is rounded to an integer the the pdfinfo output.

I recommend using pdflatex instead of converting DVI to PS to PDF. You will get much better quality output.
Comment 2 Tristan Miller 2017-09-13 12:02:17 UTC
(In reply to Adrian Johnson from comment #1)
> I recommend using pdflatex instead of converting DVI to PS to PDF. You will
> get much better quality output.

Unfortunately, this is not an option when using certain LaTeX packages, such as powerdot or pstricks.

> The problems seems to be with the ps2pdf conversion.

OK, so I should report this problem to Ghostscript?
Comment 3 Adrian Johnson 2017-09-13 12:27:44 UTC
(In reply to Tristan Miller from comment #2)
> OK, so I should report this problem to Ghostscript?

Yes.
Comment 4 Tristan Miller 2017-09-13 13:04:45 UTC
Ghostscript bug report: https://bugs.ghostscript.com/show_bug.cgi?id=698530


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.