57

Possible Duplicate:
How to make the PDFs produced by pdflatex smaller?

I wrote my thesis in LaTeX and so far I always compiled with pdflatex. The thesis is 150 pages with many pictures and graphs. The resulting PDF file is 40 MB.

Now, I'm facing the problem that for administrative purposes they need it in a file which shouldn't exceed 30 MB in size (don't ask me why).

How can I reduce the size of the output PDF? I don't mind loosing a bit of quality in the images but I don't seem to find any way of doing that.

7
  • @Fabio - are any of the individual figure files large, or do you have a very large number of small files? If you do have large figure files, what type are they (i.e. eps/pdf/jpg etc.)? Mar 28, 2011 at 16:01
  • @Ian, I do have many images, some are small some are bigger. I do have .eps, .png and .jpg .. thank you Mar 28, 2011 at 16:10
  • 3
    Perhaps look at: How to create small final PDF files for the Internet
    – Joseph Wright
    Mar 28, 2011 at 16:26
  • If you find it hard to install pdfsizeopt, then I'm willing to try running it on your thesis for you, to see if it will be likely to compress sufficiently.
    – Lev Bishop
    Mar 28, 2011 at 18:07
  • 1
    Another related question: How to make the PDFs produced by pdflatex smaller?
    – Daniel
    Jan 16, 2012 at 20:37

3 Answers 3

81

The elephant in the room are the embedded bitmaps, which can blow up the file size really fast. I have a 400 page book manuscript with lots of molecular structures rendered at 600 dpi (for print), and the overall file size is 50 Mb.

I just googled around for a way to reduce the resolution of embedded images and found that ghostscript can do this:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=small.pdf big.pdf

The level of compression is adjusted by the -dPDFSETTINGS switch:

-dPDFSETTINGS=/screen   (screen-view-only quality, 72 dpi images)
-dPDFSETTINGS=/ebook    (low quality, 150 dpi images)
-dPDFSETTINGS=/printer  (high quality, 300 dpi images)
-dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs)
-dPDFSETTINGS=/default  (almost identical to /screen)

With my file, the down-sampled images produced with the /screen and /ebook settings look very coarse, but the output of the /printer setting looks very nice on screen, while still bringing the file size down from 50 to 13 Mb. Hyperlinks were preserved. So, this seems to be straightforward and viable option.

5
  • This is an amazing find. Took my 29MB pdf down to 639K with the ebook setting.
    – Rovanion
    Nov 19, 2014 at 7:49
  • @Michael Palmer: I tried and I get an error No such file or directory. I tried with the correct directory for both the input and output files, but still same error
    – Srivatsan
    Nov 19, 2015 at 14:46
  • 1
    Thanks Mike, I think this is the "Free PDF Compressor" program on Windows. Just download it and you are good to go. I reduced my 1 GB PDF file to 23 MB with the printer option and it looked real good with hyperlinks intact- How AMAZING! Mar 15, 2016 at 15:28
  • I have a bunch of images (some sort of vector graphics stored in pdf images) in my document and this doesn't reduce the size at all for me. May 18, 2016 at 18:35
  • @highBandWidth I think of vector images as computationally defined; they contain the information necessary to re-create the image at any zoom level, which is why they don't pixelate. I'm also guessing this is why they don't compress... they contain what they need to contain to behave like this.
    – Hendy
    May 2, 2017 at 1:56
5

As described in my answer to the other question about shrinking pdf files you can use pdfsizeopt to do lossless compression of your pdf. If it turns out to be necessary to do lossy compression, then adobe acrobat professional has a "PDF optimzer" tool that can do this.

4
  • 1
    Tried running it NotImplementedError: PDF-1.5 cross reference streams not implemented Mar 30, 2011 at 11:18
  • 1
    \usepackage{pdf14}, so that tex generates PDF-1.4.
    – Lev Bishop
    Mar 30, 2011 at 12:11
  • thanks, this way it's been able to do something but then: AssertionError: sam2p_np failed (status) Mar 30, 2011 at 12:31
  • 1
    Are you using the latest sam2p from pdfsizeopt.googlecode.com/files/sam2p ? This error message is mentioned in the bug tracker, but only in relation to (unsupported) installation on windows.
    – Lev Bishop
    Mar 30, 2011 at 12:47
2

There is a package called degrade that compresses .jpg files (I've never used it, though). It may be just as easy to compress the files yourself, using suitable graphics software. It's usually just a question of opening the file, selecting save as choosing the jpeg format and adjusting the quality.

I don't know much about .png files. You could convert them into .jpg files.

It's usually best to avoid converting .eps files into .jpg files, especially if they contain text or formulae. As it happens, I've been working on a program that can reduce the size of .eps files in some circumstances. It's not quite finished yet, but if you have any .eps files that are large, I would be interested in seeing them. My email address is on my homepage (click on my name and follow the link). Alternatively you could put them somewhere on the web where I can download them.

2
  • You don't have to convert png files; pdfTeX can handle them. If you want, you can try to compress them with pngcrush. And I recommend to simply convert your eps to pdf with ghostscript (e.g. ps2pdf). Jan 17, 2012 at 0:59
  • 1
    You should never convert .png files to .jpg since this would introduce compression artifacts not present in .png files.
    – MKroehnert
    May 12, 2016 at 16:09

Not the answer you're looking for? Browse other questions tagged .