How to Reduce File Size of PDF Version of a Live Script?

21 vues (au cours des 30 derniers jours)
Nick Patterson
Nick Patterson le 19 Juin 2019
I have a live script (*.mlx) file that is about 800 kB. When I "save as PDF", the PDF file is almost 4 MB.
Now, I understand that my Live Script generates several plots, so I think that is why the file size is so bloated.
However, I would like some options to reduce this size. For example, the figures need not be at maximum quality. Also, if it takes less memory to save them as a raster scan (e.g., a *.PNG) instead of a vector graphic (e.g., a *.EPS), I would like to be able to do so. [That's just an example; I just want a means to reduce file size.]
(To answer why I care: the Live Script is part of a deliverable MATLAB toolbox (*.mltbx), and the file size of the package is important. I don't want to add 4 MB unless there's no other choice.)
My backup option is to only deliver the *.MLX file and not the *.PDF (right now we deliver both), but many users like the *.PDF version because it shows the outputs without having to run the code, and it shows what the outputs look like without errors.

Réponse acceptée

Nick Patterson
Nick Patterson le 2 Août 2019
One person suggested using an external tool (I was trying to find a MATLAB setting).
I found the following Bash command worked amazing (form 3007 kB to 277 kB):
  • gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output_small.pdf input_large.pdf
The image quality drops substantially, but the text and text colors all look great. The figures are still good enough, and a file size reduction factor of 10 is impressive. This is exactly what I needed.

Plus de réponses (1)

Lilian Smith
Lilian Smith le 31 Juil 2019
if you want to comoress your pdf , try FoneDog PDF Compressor

Catégories

En savoir plus sur Printing and Saving dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by