Pymupdf: Bookmarks not rendering in evince/Acrobat when adding to PDFs with existing bookmarks

Created on 26 Feb 2021  ·  4Comments  ·  Source: pymupdf/PyMuPDF

Hello,

Thanks again for such an awesome library. I've been using it for multiple production systems for a while now with absolutely no issues - really appreciate all of your effort on this.

Describe the bug (mandatory)

After upgrading to a newer version of PyMuPDF, using pdf.setToC() to add bookmarks to any PDF that has existing bookmarks in it runs without any exceptions, but the result PDF's bookmarks do not appear when opening the PDF using GNOME Document Viewer/evince or Adobe Acrobat.

The bookmarks seem to be viewable when using Chrome. Calling pdf.getToC() on the result PDF also shows that the bookmarks are present, per the library.

This issue only seems to appear in PyMuPDF versions 1.18.7 or 1.18.8. It ONLY seems to appear when the input PDF has existing bookmarks; when using a PDF without any bookmarks everything renders OK.

To Reproduce (mandatory)

Sample PDF and replication script are attached.
test.pdf
script.py.txt

Expected behavior (optional)

Bookmarks are viewable.

Screenshots (optional)

Input PDF bookmarks:
image

Output PDF has no bookmarks:

image

Your configuration (mandatory)

  • Ubuntu 20.04 (also tested with same result on Oracle Linux 7.8), both 64-bit
  • Python 3.7.3, 64-bit
  • PyMuPDF 1.18.7 or 1.18.8, installed via pip/wheel
  • evince version 3.36.7
  • Acrobat version 2021.001.20135
bug

All 4 comments

Good timing - I planned to publish the next version this weekend.
Let me see if this can be resolved quickly enough.
Thanks for the well prepared material!

Found it - although I don't understand what the hell is bothering Adobe.
You may know, that set_toc _always_ removes the old TOC and builds a completely new one.
As I am a performance freak, I tried an earlier idea again: re-use the freed xrefs that the old TOC had beeen using.
Switching the respective instruction off, calmed down Adobe again.
So you can download the improved version on Monday latest ...

Sounds good; no rush or urgent need from my end. Thanks for the quick attention.

Fixed in v1.18.9 currently being uploaded.

Was this page helpful?
0 / 5 - 0 ratings