I usually compress my tex PDFs with ghostscript:

pdflatex -shell-escape file.tex

gs -sDEVICE=pdfwrite        \
   -dCompatibilityLevel=1.4   \
   -dPDFSETTINGS=/prepress      \
   -dNOPAUSE -dQUIET -dBATCH      \
   -sOutputFile=file_compressed.pdf \

Normally that works well, but if I have relative links to local files, the links don't work afterwards.

Minimal example:



The link works in file.pdf but not in file_compressed.pdf. Is there any pdflatex or ghostscript setting that retains the link in the compressed version?

I use Acrobate Reader 10.1.14 for viewing, Ghostscript 9.10 and pdfTeX 3.14159265-2.6-1.40.15 (TeX Live 2014) on OS X 10.9.5.

Update: The breakage of hyperlinks had nothing to do with compressing the PDFs. The breakage happened for all re-processing of PDFs containing hyperlinks in its input PDF.

1 Answer 1


Use the Ghostscript option "-dPrinted=false" or the hyperref option "pdfa": \usepackage[pdfa]{hyperref}.

You can find more info in this post:

Set the print flag on links with hyperref to preserve them with ghostscript >= 9.25

  • 1
    The -dPrinted=false ghostscript option will have the effect to drop print annotations, so that's a bad idea in general. Thus \usepackage[pdfa]{hyperref} is probably a better solution if it has no side effects.
    – vinc17
    Nov 11, 2018 at 19:31
  • The pdfa hyperref option is actually a bad idea: if used, when the PDF file is printed, the boxes around the links are printed, making the document less readable.
    – vinc17
    Dec 6, 2018 at 15:48
  • @vinc17 what are "print annotations"??
    – pluton
    Nov 1, 2019 at 15:08
  • 2
    @pluton See general information about annotations; there is also a link to the PDF specifications. About the annotation flags, see Section 8.4.2. For instance, an annotation can have the Print and NoView flags set, in which case the annotation will be printed, but not displayed on screen. If the NoView flag is set and -dPrinted=false is used, then the annotation will be dropped by Ghostscript, according to Ghostscript bug 699830 comment #16.
    – vinc17
    Nov 4, 2019 at 12:13

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.