# Local hyperlinks broken after PDF processing with Ghostscript

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 \
file.pdf


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

Minimal example:

\documentclass{beamer}
\usepackage{hyperref}

\begin{document}
\begin{frame}
\href{run:./audio.mp3}{test}
\end{frame}
\end{document}


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.

Use the Ghostscript option "-dPrinted=false" or the hyperref option "pdfa": \usepackage[pdfa]{hyperref}.
• 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. 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. Dec 6, 2018 at 15:48
• @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. Nov 4, 2019 at 12:13