I would like to make a question because I searched on StackExchange without finding a good solution. Before importing the images on a Latex document I am used to automatically compress them to a definite resolution (therefore the size) of the images according the needs: report to be printed or sent via email. I would like to understand if there is a possibility to automatically compress them with PDFLatex maintaining also the hyperlinks. I know it is possible to use external pdf compressors to adjust the final size of the final document but the links inside it get lost. I know exists a package called Deprecate but on the readme file it is reported that it works only on Linux systems.

It would be great if there is a package allowing you to set the images resolution on the preamble (ex. 300 dpi) and change it according the need you have with that particular document. It looks strange to me that tehe is nothing able to do this. Below I post a simple generic code with image inclusion and hyperlink.


\vspace{-1 cm}
\flushleft\hspace{-1.5 cm}
\href{https://www.link.com/}\includegraphics[height=1.5cm, keepaspectratio]{example-image-duck}


Thank you in advance for every eventual support.

  • 2
    your example doesn't make much sense, you are including a vector pdf where resolution doesn't matter. If you compress with ghostscript, you have to set the print flag to links to preserve them. This is currently only possible if you use \usepackage[pdfa]{hyperref}, see also github.com/latex3/hyperref/issues/74, but this will hopefully change in the future. – Ulrike Fischer Dec 14 '20 at 9:01
  • 1
    tex.stackexchange.com/questions/379926/… seems related. – Marijn Dec 14 '20 at 9:23
  • 1
    Note also that the package you refer to is called degrade, not 'deprecate'. – Marijn Dec 14 '20 at 9:23

At the end I was able to fix this issue.

First I used \usepackage[pdfs]{hyperref} as described by Ulrike.

Then I made the conversion using Ghostscript for Windows. I created a system environment and i launched the command:

gswin32c -o output.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/print -c "[ /PageMode /UseNone /Page 1 /View [ /Fit ] " -c " /PageLayout /SinglePage /DOCVIEW pdfmark" -f input.pdf

The resolution is defined by /print which means 300dpi:

-dPDFSETTINGS=/screen  (72 dpi)
-dPDFSETTINGS=/ebook  (150 dpi)
-dPDFSETTINGS=/prepress  setting (300 dpi)
-dPDFSETTINGS=/printer (300 dpi)

/Fit is for opening the pdf document with the zoom fit to the whole page, on Page 1.

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.