Reduce PDF file size by applying Jpeg compression to all images embedded in the PDF.
Java SE8 or newer
Download code and build using Maven
All operating systems:
Unpack the archive wherever. On Windows, run
shrink-pdf.bat. On Mac or Linux, run
The PDF Shrinker supports command line arguments for automation. From the install directory, do:
java -cp "jar/*" edu.emory.cellbio.ShrinkPDF [<input> [<output>]] [-q <quality>] [-h | --headless]
<input> — Path of the PDF file to shrink
<output> — Path to save the shrunken PDF
-q <quality> — Compression quality parameter. Number between 0 (low quality, small file size) and 1 (high quality, large file size). Default, 0.85.
-h | --headless — If this flag is set, the app will use default parameter values if user values are not set. Otherwise, user input will be requested.
Extracts each image object in the PDF, applies jpeg compression, and replaces the original image
Does not check original image format. If original image format is already compressed (jpeg, jbig2, or jpeg2000), it will be recompressed as jpeg. This will always result in quality loss, but depending on the compression settings, it may increase file size.
Uses Apache PDFBox to read, parse, and write PDF files (included in the pre-built app download)