[Tex/LaTex] moderncv – filesize of pdf too big

file sizegraphicsmoderncvpdftexpng

I managed to work out how to create a job application that is entirely written in the moderncv style. I use the moderncv class itself for my CV and the attachments (making each document a section with one to several scanned images embedded). For the cover letter I use the moderncv-based proposal of yes-man from a mrunix thread.

My problem is the file size of the attachment pdf. I have lots of certificates and documents to show. I scanned them and converted them from pdf to png and use

\usepackage{float}
\floatstyle{boxed} 
\restylefloat{figure}

to show them in a pretty way.

But with only a selection of 18 images the pdf has 14 MB, with all images 28 MB. So I reduced filesize with gimp and then scaled the images with 1.5 instead of 0.6 – but the result is unacceptable low resolution (bad image quality).

Is there a solution out of this trap, i.e. is there a way to bring down pdf file size to 2-3 MB with ca. 18 almost full page png images embedded in a moderncv document – without losing readability and too much of image quality?

EDIT:
I tried black&white with good (!) results:

-rw-r--r-- 1 tj users  1288744 25. Sep 20:27 scan1.png
-rw-r--r-- 1 tj users    70618  6. Okt 15:19 scan1b.png
-rw-r--r-- 1 tj users   496796  6. Okt 18:02 scan1c.png
-r-xr-xr-x 1 tj users  1743427 25. Sep 14:26 scan 1.pdf

scan1 is the default conversion from the pdf to png, scan1b is the result of reducing image size (to unreadable, unfortunately), and scan1c is scan1 in black&white – less than half the size, quite good.

Best Answer

There is no package makemypdfsmaller.sty which reduces the PDF file size without removing information. However, there are a few things you can do:

Reduce number of images

Do you really need to include eighteen images? Maybe sixteen or twelve is enough.

Reduce image size

You can use imagemagick (or gimp or …) to reduce the image size. You have to experiment which values are acceptable.

convert -geometry 75% input.png output.png

Reduce amount of colours

Especially when the image contains text on white background or just a few colours, like certificates often do, you can significantly reduce the image size. Try different values, e.g. 4, 8, 16

convert -colors 16 input.png output.png

Run optipng on the file

The program optipng can shrink the file about one to four percent more after you have reduced the amount of colours. Not much, but it's lossless. The slowest setting with the highest compression is -o7.

optipng -o7 input.png

Increase PDF compression

Set \pdfcompresslevel9. This also does not help much, but maybe it helps to squeeze it just enough to fit into a file size limit.

Reducing the final PDF

When you already created the PDF or you don't have access to the images any more, you can use ghostscript to reduce the resolution of the final PDF. Use for instance the setting -dPDFSETTINGS=/ebook. Here is an example.

gs \
  -sOutputFile=output_file.pdf    \
  -sDEVICE=pdfwrite               \
  -dNOPAUSE                       \
  -dBATCH                         \
  -dPDFSETTINGS=/ebook            \
  input_file.pdf

/ebook sets the resolution to 150 DPI. Other settings are /screen (75 DPI) or /print (300 DPI).