Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a 72.9MB PDF file that I need to shrink into under 500KB.

The file was a JPEG image that I had scanned, and then converted to pdf.

share|improve this question

closed as too broad by Braiam, Mitch Jun 16 '14 at 12:38

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs. If this question can be reworded to fit the rules in the help center, please edit the question.

it depends on what consumes the space...need a lot more information. compressing image space could help, but if you're trying a large file heap spray, that won't work. seriously need more info. –  hbdgaf Mar 16 '12 at 17:14
convert it to DjVu, instead trying to reduce to impossible sized PDF (according source) –  zetah Mar 16 '12 at 17:22
the file was a jpeg image that I had scanned, and then converted to pdf. –  tamimym Mar 16 '12 at 19:53
It only seems to help filesize a little bit, but pdfopt has a simple syntax and improves loading and page-turning speed in the iPad era. :-) –  Ari B. Friedman May 31 '12 at 0:53
PDF to PS is not effective in scanned PDF file, I try to convert 56 MB pdf into ps file but ps file convert into 1.3 GB and again ps2pdf is converted in 45 MB file –  user124118 Jan 18 '13 at 5:32

10 Answers 10

up vote 35 down vote accepted

aking1012 is right. With more information regarding possible embedded images, hyperlinks etc.. it would be much more easier to answer this question!

Here are a couple of script and command-line solutions. Use as you see fit.

share|improve this answer
I should point out that if you're trying to downsize a >10MB PDF file to under 500KB, you'll be sacrificing a lot of content, because its strongly unlikely you'll be able to get that PDF down to the size you want... –  Thomas W. Mar 16 '12 at 17:31
Thank you very much for your suggestions, the ghostscript shell worked wonders and shrank it down to 460KB :) –  tamimym Mar 16 '12 at 19:56
You are very welcome tamimym, and i am glad, that one of the suggestions fitted your needs!! (: –  v2r Mar 16 '12 at 20:55

Use the following ghostscript command:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

If the -dPDFSETTINGS=/screen setting is too low quality to suit your needs, replace it with -dPDFSETTINGS=/ebook for better quality, but slightly larger pdfs. Delete the setting altogether for the high quality default, which you can also explicitly call for with -dPDFSETTINGS=/prepress.

share|improve this answer
One can also make a Nautilus script to access this function for every file. –  Sina May 7 '13 at 15:51
This should be the accepted answer. ghostscript is the PDF, XPS and PS implementation for unices and can do basically everything delivering best quality... –  dom0 Oct 2 '13 at 17:27
@Sina: There is actually a Nautilus Script with a simple Zenity-based GUI that utilizes this gs command with all its quality-level options: launchpad.net/compress-pdf –  Sadi Oct 25 '13 at 11:47
This is the right answer for this question (compressing a pdf that is mostly bitmap data). I found that the screen setting was too low quality for me, but ebook worked well, cutting a 33Mb scan-based PDF down to 3.6Mb, and keeping it very readable. Other options for the -dPDFSETTINGS option are listed here: milan.kupcevic.net/ghostscript-ps-pdf, and it might be a good idea to include them in this answer. –  naught101 Dec 2 '14 at 1:13
gs available configuration parameters: ghostscript.com/doc/current/Ps2pdf.htm –  Antonios Dec 11 '14 at 23:41

My favorite way to do this is to convert the pdf to ps and back. It does not always work, though, but when it works the results are nice:

pdf2ps input.pdf output.ps
ps2pdf output.ps output.pdf

Good luck

share|improve this answer
This is a very simple and effective way to do it. I was surprised to see how much this method compressed the files. Thanks you! –  Gabriel Apr 8 '13 at 12:59
Despite the fact that this one approach became my favorite solution to compress pdf files, it breaks up url links the document may have (which does not happen with @Michael D's approach). Apart from that, awesomeness is all I can think of running this snippet! (: –  Rubens Dec 6 '13 at 11:01
@Rubens Ah. Did not know about the fact that it breaks the url links. Thanks for adding that. –  don.joey Dec 6 '13 at 12:19
This bypasses password protection...just sayin' –  jojo Jan 6 at 20:28

If you have a pdf with scanned images, you can use convert to create a pdf with jpeg compression.

For example:

convert -density 200x200 -quality 60 -compress jpeg input.pdf output.pdf

Adjust density and quilty to your needs.

I was able to achieve great compression ratios for scanned/photographed documents (depending on the settings). Depending on the document source you might want to reduce the color depth (-depth argument)

share|improve this answer

I needed to downsize a pdf that contained full color scans of a document. Each of my pages was a full color image as far as the file was concerned. They were images of pages containing text and images, but they were created by scanning to an image.

I used a combination of the above Ghostscript command and one from another thread.

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dDownsampleColorImages=true /
-dColorImageResolution=150 -dNOPAUSE  -dBATCH -sOutputFile=output.pdf input.pdf

This reduced the image resolution to 150dpi, cutting my file size in half. Looking at the document, there was almost no noticeable loss of image quality. The text is still perfectly readable on my 2012 Nexus7

share|improve this answer
+1 for down sampling images but keeping text as vectors. Made a huge difference in side without making my text pixelated. –  Jason O'Neil Dec 8 '14 at 8:34

I just encountered this problem myself. If using simple scan, select text mode for low resolution scans and you won't need to worry about the command line stuff. Just saying.

share|improve this answer

Since this link was first for me when I searched in Google, I thought I'd add one more possibility. None of the above solutions was working for me on a pdf exported from Inkscape (15 mb), but I was at last able to shrink it down to 1 mb by opening it in GIMP, and exporting as pdf again.

Another option that came close (but text was a little fuzzy) was ImageMagick's convert utility:

convert -compress Zip input.pdf output.pdf
share|improve this answer
I guess this is what you meant by "a little fuzzy", but just to clarify, convert -compress Zip appeared to rasterise all vectors. –  Sparhawk Feb 22 at 3:39

Vectorizing all fonts will help. Don't embed fonts into the file.

Use small image resolution: most of the time you really dont need HD pictures. Be careful with image software like Gimp, it can make very large compressed file (beware how you compress it). I don't like proprietary softwares but some Adobe Photoshop compression tools are better than Gimp one.

More: do you need to put the image into a PDF file?

It's very simple, but more than image resolution, you can simply change the document size...

@Lord of Time is right: switch from 72Mo to 500Ko will be hard without changing something radically.

share|improve this answer

load image or even pdf file into inkscape.

From inkscape: Save in vector format (as the native .svg).

Import vector files into scribus, edit layout and export/save as .pdf from there

share|improve this answer

shrinkpdf cut down the pdf size in my case from 5.6 MB to 1.1 MB choosing to go with 100 DPI. The original scanned document was in 200 DPI

share|improve this answer

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