3

I have a PDF file with bookmarks (aka index and document outline), which seem to specify the zoom in which the document is displayed after the link is followed. I know this because when I view the file in Evince and click on a bookmark, Evince automatically changes the zoom level.

Although this is documented in ISO 32000-1:2008 (Section 12), I don't like this behavior. I want my PDF viewer to display the document in the same zoom level after using bookmarks.

A relatively new key allow-links-change-zoom in dconf is supposed to remedy this problem. However, even after setting the key to false, Evince continued to show the previous behavior. (Perhaps I might have needed to reboot the computer; but I can't check this because I don't have access to a newer version of Evince right now.)

That is why I've been trying to remove the zoom information from the bookmarks of the PDF file.

Keywords like /XYZ, /Fit and GoTo that appear in the specification does not occur in the file. Perhaps the bookmark is encoded somehow. So erasing the data by hand or by sed doesn't seem to work.

How can I do the task?

1

You might need to uncompress the file using pdftk to actually be able to find the destination keywords.

If you still have a copy of the v1.7 PDF standard, you can also check section 8.2 for more details about the syntax. The section about named destinations might be of help.

Here is a little script I use for stripping the zoom factors from bookmarks in PDFs:

#!/bin/bash

# decrypt the file
pdftk "$1" output decrypted.pdf && \
pdftk decrypted.pdf output uncompressed.pdf uncompress && \
# remove zoom factors in bookmarks
sed 's#/Fit#/XYZ#g' uncompressed.pdf > uncompressed_output.pdf && \
# compress the output
pdftk uncompressed_output.pdf output output.pdf compress && \
mv "$1" "$1.original" && \
mv output.pdf "$1" && \
rm decrypted.pdf uncompressed.pdf uncompressed_output.pdf

Save this to a file removezoom.sh and make it executable. You can then call it as

~$ ./removezoom.sh yourFile.pdf

Edit: Ah, sorry, I was referring to section 8.2 in the document formatted by Adobe, named "PDF Reference, sixth edition". The formatting is different from the original ISO document, or so Library of Congress claims.

2
  • 1
    Welcome to the site, and thank you for your contribution. May I recommend that you turn your script into a self-contained file which you can simply call with the file to operate on as argument, as in ./remove_zoom.sh myfile.pdf. It should be as simple as replacing $PDF_FILE_PATH with $1 (and adding the appropriate #!-line at the beginning).
    – AdminBee
    Jun 8 at 7:41
  • @AdminBee Done. Jun 10 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.