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

17 views (last 30 days)
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.

Accepted Answer

Nick Patterson
Nick Patterson on 2 Aug 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.

More Answers (1)

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

Categories

Find more on Tables in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!