I've got a rather large (~100MB) PDF document with lots of images in it (as illustrations and background images), and I'd like to have a copy of that pdf without images but I can't find out how to do that.

I'm not talking about converting it to text only, I'd like to keep paragraphs/tables/multi-columns as they are.

I'm comfortable with command line and have several computers with different distributions that I can use.

  • As we're talking about a 500 pages document with multiple images on each page, I'm looking for an automated way to remove every picture. – Ornux Jun 6 '14 at 14:35
cpdf -draft original.pdf -o version_without_images.pdf

It is not in the repositories but you can find a download (pre-compiled or source) on their website.


15.1 Draft Documents

The -draft option removes bitmap (photographic) images from a file, so that it can be printed with less ink. Optionally, the -boxes option can be added, filling the spaces left blank with a crossed box denoting where the image was. This is not guaranteed to be fully visible in all cases (the bitmap may be have been partially covered by vector objects or clipped in the original). For example:

 cpdf -draft -boxes in.pdf -o out.pdf
  • 1
    That is exactly what I was looking for. The output file is just perfect. Thank you so much! – Ornux Jun 6 '14 at 15:06
  • @Rinzwind Please note that the link "their website" actually goes to a zip file. – Jos Jun 6 '14 at 16:02
  • Hmm .. for me it keeps adding almost random lines over and across text, and the file size actually grows slightly, rather than shrinking. – Henning Koehler Jul 4 '17 at 5:56

The latest releases of Ghostscript can do this too. Just add the parameter -dFILTERIMAGE to your command.

The are even two more new parameters which can be added in order to selectively remove content types "vector" and "text":

  1. -dFILTERIMAGE: produces an output where all raster images are removed.

  2. -dFILTERTEXT: produces an output where all text elements are removed.

  3. -dFILTERVECTOR: produces an output where all vector drawings are removed.

Any two of these options can be combined. (If you combine all 3, you'll get all pages getting blanked...)


Here is the screenshot from an example PDF page which contains all 3 types of content mentioned above:

Screenshot of original PDF page containing "image", "vector" and "text" elements.
Screenshot of original PDF page containing "image", "vector" and "text" elements.

Running the following 6 commands will create all 6 possible variations of remaining contents:

 gs -o noIMG.pdf   -sDEVICE=pdfwrite -dFILTERIMAGE                input.pdf
 gs -o noTXT.pdf   -sDEVICE=pdfwrite -dFILTERTEXT                 input.pdf
 gs -o noVCT.pdf   -sDEVICE=pdfwrite -dFILTERVECTOR               input.pdf

 gs -o onlyIMG.pdf -sDEVICE=pdfwrite -dFILTERVECTOR -dFILTERTEXT  input.pdf
 gs -o onlyTXT.pdf -sDEVICE=pdfwrite -dFILTERVECTOR -dFILTERIMAGE input.pdf
 gs -o onlyVCT.pdf -sDEVICE=pdfwrite -dFILTERIMAGE  -dFILTERTEXT  input.pdf

The following image illustrates the results:

Top row, from left: all "text" removed; all "images" removed; all "vectors" removed. Bottom row, from left: only "text" kept; only "images" kept; only "vectors" kept.
Top row, from left: all "text" removed; all "images" removed; all "vectors" removed. Bottom row, from left: only "text" kept; only "images" kept; only "vectors" kept.


While @Rinzwind answer is the Right Thing, I would like just to comment the "midway" solution. You can normally reduce greatly the size of the images using ghostscript with

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen \
   -dNOPAUSE -dQUIET -dBATCH -sOutputFile=small.pdf original.pdf

...it is sometime really handy for proofreading. The manual page for writing PDF is here.

  • @KurtPfeifle /screen will (among other things) set the bitmap image(s) resolution to 72dpi. So yes, if you have images at smaller DPI, it can increase the file size. This is the reason why I used the word "normally" (in the sense of "not always, but quite often"). Feel free to downvote whatever you want. – Rmano Jun 16 '16 at 16:55
  • Run this command: for s in screen default ; do gs -o /dev/null -sDEVICE=pdfwrite -dPDFSETTINGS=/${s} -c "currentpagedevice {exch ==only ( ) print === } forall" | sort | tee ghostscript---pdfwrite-PDFSETTINGS-${s}--pagedevice-settings.txt; done. It will produce two text files which you can compare using sdiff -sbB $[file1}.txt ${file2}.txt. Now you know exactly and completely all the different settings introduced by -dPDFSETTINGS=/screen! – Kurt Pfeifle Jun 16 '16 at 17:18
  • Done. Still can't see which option can give a bigger file in /screen than in /default --- 72dpi versus 150dpi, optimized, discard EPS preview... but hey, not a big problem. People will test and choose the better solution. – Rmano Jun 16 '16 at 17:41
  • I'm sorry -- maybe I've to apologize now for the cheekyness of my 1st statement. To be honest, I just seem to remember from my previous investigations (a few yrs back) that /screen gave really bad results. Possibly my memory fails, or I mixed it up with /epub. The command I gave you was from memory because I was quite sure it would show what I meant. Now I re-ran it again, I no longer see what I expected: more extended tests I did run some years ago. Then lots of (CID?/CFF?) fonts got rasterized bloating sizes of resulting PDFs. I must re-visit the issue again, once I've more time... :-) – Kurt Pfeifle Jun 16 '16 at 18:38

You can use master pdf editor, delete those images and save as a new pdf file. You can download it from Ubuntu software center.

  • I just installed it to try but I see no automated way to do that. Given that it is a 500 pages document, I don't see manual removal as a solution here. Did I miss something ? – Ornux Jun 6 '14 at 14:32
  • no you didn't miss anything i thought images are large size so you want to remove them, never thought of so many images. anyway nice question. – Sudheer Jun 7 '14 at 3:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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