Optimize a PDF or extract part of it with ghostscript
I am writing some largish lecture notes, which now are around 120 pages long. The problem with this document is that it is full of attractive images that are needed to make the content more clear and amenable, and these images are not optimized in size: they come from papers, simulations, drawings, etc, and each of them has been produced with different means and the final size of the image might be much smaller than what the resolution allows for.
So, the result is that I have this large file which is 16Mb large, which I will call notes.pdf I need to send a few chapters of this file to my colleagues and students and when I cut the file, it still is too large, 12-13Mb, as Adobe or OS X are not able to really trim the size.
If you run Linux or Mac OSX, here is what you can do:
gs -sDEVICE=pdfwrite -dBATCH -dNOPAUSE -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -sOutputFile=small-notes.pdf notes.pdf
This reduces the size quite significantly by (i) reducing the size of figures to the resolution that is needed for the given device (screen), (ii) eliminating fonts that are already standard and which are included by PDFLaTex, (iii) compressing the output. In my case, down from 34Mb to 13Mb.
If I need to select a few pages, tell that to Ghostscript:
gs -dFirstPage=1 -dLastPage=73 -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dBATCH -dNOPAUSE -dPDFSETTINGS=/screen -sOutputFile=small-notes.pdf notes.pdf
If you run Windows but have MikTeX installed, the same commands work, but you have to replace