The order of preference when files with the same name and different extensions is
.png .pdf .jpg .mps .jpeg .jbig2 .jb2 .PNG .PDF .JPG .JPEG .JBIG2 .JB2
which is stored in the macro \Gin@extensions
. So if you have both image.png
and image.pdf
, pdflatex
will load the former.
If you are mixing case in extensions, then
\DeclareGraphicsExtensions{%
.png,.PNG,%
.pdf,.PDF,%
.jpg,.mps,.jpeg,.jbig2,.jb2,.JPG,.JPEG,.JBIG2,.JB2}
will ensure that PNG are always preferred over PDF files. For the final version it will be sufficient to switch the two lines.
A handier way, suggested by Heiko Oberdiek, is to use the package grfext
:
\usepackage{grfext}
\PrependGraphicsExtensions*{.png,.PNG}
that will have the same effect without the need to check in pdftex.def
for the list of extensions.
If you want also automatic conversion, you can say
\usepackage{graphicx}
\usepackage{epstopdf}
\epstopdfDeclareGraphicsRule{.pdf}{png}{.png}{convert #1 \OutputFile}
\DeclareGraphicsExtensions{%
.png,.PNG,%
.pdf,.PDF,%
.jpg,.mps,.jpeg,.jbig2,.jb2,.JPG,.JPEG,.JBIG2,.JB2}
When image.pdf
exists but not image.png
, the file image-pdf-converted-to.png
will be created and loaded in its place. Add the options you prefer between convert
and #1
(for example -density 100
or something like that).
You need to call pdflatex
with the --shell-escape
option for this automatic conversion to work. Of course you'll comment out the \epstopdfDeclareGraphicsRule
command for the final version, when only PDF files should be loaded (and switch the order of precedence in the lines below).
Ghostscript can convert color documents into grayscale. Example commandline:
gs \
-o grayscale.pdf \
-sDEVICE=pdfwrite \
-sColorConversionStrategy=Gray \
-sProcessColorModel=/DeviceGray \
/path/to/your.pdf
The most recent version of Ghostscript can also check for the CMYK ink coverage of PDF documents (not image by image, but page by page), using a new "device" called inkcov
. Check for the ink coverage of an example PDF:
gs -o - -sDEVICE=inkcov /path/to/your.pdf
Example output:
Page 1
0.00000 0.00000 0.00000 0.02230 CMYK OK
Page 2
0.02360 0.02360 0.02360 0.02360 CMYK OK
Page 3
0.02525 0.02525 0.02525 0.00000 CMYK OK
Page 4
0.00000 0.00000 0.00000 0.01982 CMYK OK
Here 1.00000 would mean 100%, 0.02525 means 2.525% and 0.00000 means 0% ink coverage. You can see here that pages 1+4 are using no color, while pages 2+3 do. This case is particularly 'nasty' for people who want to save on color ink: because all the C, M, Y (and K) values are exactly the same for each of the pages 2+3, they possibly could appear to the human eye not as color pages, but as grayscale (or "rich" grayscale in the case of page 3) anyway. (That is, if each single pixel is mixed with these color values -- of course, if the page is made by four different squares of the same size using "pure" colors each, then you'd get the same ink coverage result).
Now convert the original PDF to a grayscale one, using the command I initially gave. Then check for the ink coverage distribution again (note how the addition of -q
to the parameters slightly changes the output format):
gs -q -o - -sDEVICE=inkcov grayscale.pdf
0.00000 0.00000 0.00000 0.02230 CMYK OK
0.00000 0.00000 0.00000 0.02360 CMYK OK
0.00000 0.00000 0.00000 0.02525 CMYK OK
0.00000 0.00000 0.00000 0.01982 CMYK OK
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.
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
Run
optipng
on the fileThe 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
.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./ebook
sets the resolution to 150 DPI. Other settings are/screen
(75 DPI) or/print
(300 DPI).