I have used Ghostscript to compress the pdf output of some large files as it seems to do a better job of getting rid of duplicate font information than Adobe Acrobat (which sometimes loses certain math glyphs). I use XeLaTeX and my documents contain lots of pdf graphics, each of which were also produced by XeLaTeX, all of which contain the Calibri font found on Windows.

The command I use is gswin64 -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=foo-compressed.pdf foo.pdf, which I found in an answer here.

My documents now include some interactive 3D graphics using the \includemedia command of the media9 package. Each of these 3D graphics is created with Asymptote and are in the .prc format.

When I use the above Ghostscript command to compress the file, all the .prc information is lost - the 3D graphics are no longer interactive. I tried changing the compatibility level of the pdf to 1.7, but that didn't help.

Is there a way to use Ghostscript without losing the .prc information?

  • Related question: Is there a way to purposefully loose interactivity at the source code level to reduce the file size? This is especially interesting for people using PDF viewers that don't support asymptote's interactive content in the first place.
    – Janosh
    Mar 29, 2016 at 20:58
  • @Casimir The way I handled this was to make a macro that inserted graphics, such as a \myincludegraphics command that responded to a Boolean usethreeDgraphics. When this Boolean was True, then the image created also had the .prc information encoded (and the file size was larger). When this Boolean was False, my command \myincludegraphics just inserted a picture, and not the .prc information.
    – GregH
    Mar 30, 2016 at 18:28
  • If it doesn't have to be ghostscript then maybe qpdf with --compression-level=9 --recompress-flate would be acceptable. You might need other options
    – Doc Octal
    Jul 17, 2021 at 22:25


You must log in to answer this question.

Browse other questions tagged .