Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
2  
have you tried converting your images to b/w? –  Juri Robl Oct 6 '12 at 14:23
2  
PNG certainly is not the best format for scanned documents! Is there any particular reason you convert your scans from PDF to PNG before including them into your attachments PDF? I would either leave them as PDFs (maybe size-optimized) or convert them to JPG to get a good quality/size ratio. –  Daniel Oct 6 '12 at 18:30
    
@Daniel Probably a very naive answer, but my LaTeX book tells me JPG isn't supported by LaTeX, and out of the box it isn't - while I'm sure there is an easy solution for that. But I wasn't aware of any disadvantages of PNG. –  user17106 Oct 6 '12 at 19:06
1  
That information is wrong: pdflatex supports PDF, JPG, and PNG out of the box, latex + dvips supports only EPS. I am not aware of any driver that supports PNG, but not JPG. Anyway, have you tried not converting your scans? –  Daniel Oct 6 '12 at 20:02
1  
I would not convert scanned text documents to JPG. JPG is made to compress photorealistic images and nothing else, especially not text. It will produce ugly artefacts at sharp edges which look unprofessional, especially in a CV. I would rather prefer a lower resolution PNG to a JPG with artefacts. When PNG is used it should not be too hard to include 18 images in 3 MiB, if they are not too colourful. –  Marco Oct 6 '12 at 20:09
add comment

2 Answers

up vote 8 down vote accepted

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).

share|improve this answer
    
Thank you very much, didn't expect to get such an in depth answer. Have to try out the several steps, but this will sureley help me a lot. –  user17106 Oct 6 '12 at 16:10
    
In addition to the steps above, you can also play with the quality / compression level of the converted pngs, e.g. by specifying -quality 95 when using convert. Check the imagemagick manual for a description of the possible options. –  Xavier Oct 8 '12 at 15:59
    
The quality setting sets the compression for PNG images. Since it's lossless it should always be set to maximum level (at least in this case). The optipng step takes care of that automatically. There's not need to do that manually. –  Marco Oct 8 '12 at 17:27
add comment

As a side-effect of trying to merge all my CV pdf-files (cover-letter, CV, attachments) into one pdf-file, I discovered that using the merge-script below is a perfect method of shrinking the pdf-files too, so I would like to share it, you can find the original here. It shrinks files with a total of more than 5 MB to one file with less than 1 MB:

gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite
\ -sOutputFile=output.pdf file1.pdf file2.pdf file3.pdf

If you use it recurrently, you can think of creating a bash script like the following:

#!/bin/sh
gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile="$@"

which you will then use simply as:

mergepdf output.pdf file1.pdf file2.pdf file3.pdf

Change a4 to letter or to any other paper size you are using.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.