39

I have a PDF that contains a scan image of a document. I want to save the contents of this PDF as an image so that I can then run it through an OCR program that only accepts .jpg, .png, and .gif type files.

How do I save/convert this PDF to one of those image formats?

EDIT: One way I've found to do this is to click on each page. Copy to clipboard. Paste to Paint.net and then save. However, this is cumbersome as it appears you can only select one page at a time in Acrobat Reader.

1
  • An option that worked for me was to import PDF into NASP2 (an excellent OSS product in itself, btw), then peeking necessary pages and saving as JPG. (pdfimages didn't work on Windows 7. No matter what i tried, it ignored command line options and kept saving pages in some alien format). nb: SU distrust me to "answer" properly, thus sneaking as a comment here.
    – esteewhy
    Nov 26, 2023 at 16:30

12 Answers 12

22

Please pay close attention to pooryorick's answer, in which he points out how sleske's answer is actually a much better answer for this particular problem.


Use GhostScript. This command works for me:

gs -dBATCH -dNOPAUSE -sDEVICE=png16m -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -r150 -sOutputFile=output%d.png input.pdf

There are multiple png pseudo-devices, differentiating on color depth: pngmono, pnggray, png16, png256, png16m, and pngalpha. Choose whichever one suits you the best.

You can also use jpeg, but unless you have a disk space issue, you want as high a quality as you can manage for your OCR, and that's not jpeg.

GhostScript no longer has support for gif, but I can't imagine why you'd need that, what with png256 support.

3
  • I love GhostScript, and if you want the convenience of a GUI for setting options, viewing, etc try GSview pages.cs.wisc.edu/~ghost/gsview
    – Dennis
    Sep 30, 2009 at 18:37
  • Will the output be one huge image?
    – Xonatron
    Jul 21, 2015 at 20:45
  • 1
    @Xonatron: No. One image per page. The %d in the output file name is a variable that is replaced with the page number. (Almost certainly raw numbers, not the number inside the PDF.)
    – wfaulk
    Jul 23, 2015 at 16:06
20

Install Imagemagick. Open a cmd window or terminal:

convert myfile.pdf myfile.jpg

The output will be 1 jpg file for each page in your pdf, test-0.jpg, test-1.jpg, etc.

3
  • +1 for ImageMagick, but -2 for suggesting it for the wrong job. JPEG is good for photos, but it is the worst format to use when you have sharp egdes and high contrasts (as you typically have with black text/characters on white background). Also, ImageMagick does not do the conversion work itself, it uses Ghostscript in the background as its "delegate" slave. So doing it with Ghostscript directly gives you more control over the parameters used. And then choose TIFF (not JPEG) as the output format, for chris's sake! May 28, 2011 at 14:49
  • 1
    Note on windows, make sure you install Ghostscript 32-bit first.
    – User
    Aug 13, 2014 at 0:07
  • 2
    Be aware of the density, depth, and quality flags that can help you optimize your output. For example: convert -density 300 -depth 8 -quality 85 a.pdf a.png More info
    – Nick
    May 21, 2016 at 4:47
16

pdfimages can extract embedded images from a PDF. It will not convert a whole PDF page to an image. It's included in Xpdf tools or Poppler utils.

This is useful if the PDF contains text and images, and you want only the images. Also, it will extract the images in their original format, so no loss of quality is involved (unlike programs which render the whole page and then convert it to e.g. JPEG).


List all images from mydocument.pdf:

pdfimages -list mydocument.pdf

Extract all images from PDF mydocument.pdf to individual files named mydocument-image-0000.jpg, mydocument-images-0001.jpg and so on:

pdfimages -j mydocument.pdf mydocument-image

Option -j makes it write embedded JPEG-compressed images as JPEG files, not as PBM/PGM/PPM files (which are uncompressed and huge). Note that images may still be written as PBM/PGM/PPM files, if that's how they were stored in the PDF input file.

If you're using Poppler I recommend replacing it with -all to write JPEG, JPEG2000, JBIG2, and CCITT images in their native format. CMYK files are written as TIFF files. All other images are written as PNG files.

2
  • For reference, simple usage is pdfimages -j "yourinputfile.pdf" "outputimages" which will make "outputimages-0000.ppm" (or "outputimages-0000.jpg" if they're the right format). .NET examples can be grafted from here or here
    – drzaus
    Aug 18, 2017 at 18:31
  • A caveat is that it might not be able to save the file as a JPG, but rather a PPM
    – drzaus
    Aug 18, 2017 at 19:26
10

You can do this using adobe reader:

  1. Click the image. It will be highlighted.
  2. Copy (Ctrl-C) and paste it into Paint.
  3. Save as any file type you like.
3
  • 2
    interesting to know, Adobe Reader has a setting to override the dpi of images taken with the snapshot tool, when set to 300dpi, you'll get snapshots that are ready for print (by default the screen resolution is taken, which generally is too low to re-use in other work) Sep 30, 2009 at 17:49
  • 3
    +1 for simplicity. Most PDF reader allow you to do this.
    – Decio Lira
    Sep 30, 2009 at 17:49
  • 4
    What if your PDF has 10000 pages of images? Do you have to do this 10000 times?
    – Guy
    Oct 1, 2009 at 4:51
10

Except for the answer mentioning pdfimages, all of the other answers fail to mention that their solutions actually transcode the embedded images. I.e., those solutions do not simply extract the original image, but modify it, possibly to the detriment of the image, during the process. Only pdfimages extracts the original image. This is true of Ghostscript, Imagemagick, Adobe Reader, PDFFill, PDF Xchange Viewer, OS X Preview, and most other PDF software.

2
  • Given the context of the question, this is actually a very good point.
    – wfaulk
    Jul 23, 2015 at 16:09
  • FWIW, "PDFill PDF Tools" does allow you to set the DPI for the save-as-image, very handy. Thus each page (starting from text, images, whatever objects) gets saved, for example, to a high-res PNG at 4961x6520.
    – Chris O
    Oct 3, 2015 at 15:59
4

PDFill PDF Tools is probably the easist way to convert your PDFs to images on Windows. It'll let you export all the pages in the PDF to separate images in one shot. It also has a lot of other features available for free, which are only available in other PDF viewers if you purchase the commercial or "Pro" version.

Use the "Convert PDF to Images" button (button #10) in the screenshot below.

PDFill PDF Tools screenshot

If you need to concatenate the images into one very tall image so you only have to feed one file to your OCR program, you can use IrfanView

2
  • note that this will install two different tools on your system. The main one being PDFill Editor, which is the one you don't need. Go into start menu to open this one. I was saved by the screenshot realizing that something was wrong before I uninstalled.
    – ufotds
    May 7, 2011 at 19:59
  • Yes, I guess I failed to mention that it also installs a shareware version of PDFill Editor, as well as a PDF printer. Any files created with PDFill Editor will have a watermark unless you buy the editor for $19.99, but the PDFill PDF Tools Free utility doesn't require any purchase. In the version I have, you can't uninstall PDFill Editor without also uninstalling PDFill PDF Tools Free, but having PDFill Editor installed doesn't harm anything.
    – rob
    May 9, 2011 at 18:08
2

Since you didn't include an OS tag I'll include an OSX answer:

PDFs by default open in Preview.app which allows you to use File -> Save-As:

  • GIF
  • ICNS
  • JPEG
  • JPEG-2000
  • BMP
  • OpenEXR
  • Photoshop
  • PNG
  • TGA
  • TIFF
2

(Non-free) Acrobat professional does this:

Advanced->Document Processing->Export all images...

0

Also PDF Xchange Viewer (Free) will do export-to-file. File → Export → Export to image.

Not only that, but I think it's the best free PDF viewer for Windows, and it has some nice markup capabilities. I have a license for Adobe Acrobat and I still prefer this unless I'm doing extensive editing, which is rarely.

1
  • This looked promising, until I discovered that the option to export to image is disabled fro password-secured PDFs.
    – Mitch
    Sep 30, 2016 at 7:19
-1

If the file is less than 5MB and you aren't worried about privacy/confidentiality, then is a handy online service at http://www.go2convert.com/ that can do a lot of graphic conversions (including pdf to jpeg)

1
  • Just tried and it gave this error message "Sorry! This image could not be converted correctly."
    – Guy
    Oct 1, 2009 at 4:54
-2

If the image exceeds the size of you screen, you may use FastStone Capture (the "Capture Scrolling Window" feature) and save the image as a JPEG.

alt text

1
  • That's a very roundabout way of grabbing an image. OP already has a better solution (mark page in Acrobat).
    – sleske
    Feb 23, 2016 at 8:08
-2

You can check out this article.

It lists out 6 different ways to convert the pdf into images.

Convert PDF to JPG (The Web Way)

PDF to JPG Converters for The Desktop

1
  • erm.. Why downvoted?
    – noob
    Apr 16, 2013 at 6:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .