How to convert a PDF document to PNG?
Solution 1
This is overkill for what you need, but in the absence of another answer, GIMP can do this for you. Just install it, open the PDF, and save-as a PNG.
Solution 2
If you have imagemagick installed, you can just type:
convert myfile.pdf myfile.png
Though personally I prefer the results obtained from pdftoppm from Poppler utilities:
pdftoppm -png myfile.pdf > myfile.png
Solution 3
Windows: Install PDFCreator and open your PDF. Print it to the PDFCreator printer (or whatever you called it) and hit save. When you hit save, after choosing a filename, set the filetype to PNG.
Linux: Install ImageMagick (on Ubuntu: sudo apt-get install imagemagick
) and then in a terminal type: convert [Input PDF File.pdf] [Output PNG File.png]
.
Mac OS X: Open the PDF in Preview and in the Save As dialog, set the filetype to png.
Solution 4
You could also use GS
:
"c:\Program Files\gs\gs9.10\bin\gswin64.exe" -dBATCH -dNOPAUSE -sDEVICE=pnggray -r300 -dUseCropBox -sOutputFile="path_to_png_files\pdffilename-%03d.png" "path_to_pdf_file\pdffilename.pdf"
The path to GS
should be adjusted based on your installation.
The DEVICE
parameter here will specify grayscale. You can also output with color instead. These settings will allow you to output to 24-bit color, 300 dpi PNG files using the RGB.icc color profile:
-sDEVICE=png16m -sOutputICCProfile=default_rgb.icc -r300
Compared to convert
, GS
seems to run much faster, and it is more suitable for big batches of conversion.
Solution 5
Another way is
inkscape -d 300 -e "$filename.png" "$filename.pdf"
(you can omit -d 300
if you only need 96 dpi).
However, inkscape
may have problems with the fonts, which is why I prefer convert
from ImageMagick (see
frabjous' and digitxp's answers).
Raymond
Updated on September 17, 2022Comments
-
Raymond over 1 year
Is there a free way to convert a PDF document to a PNG image?
-
Admin over 13 yearsI asked a similar question last year on Stack Overflow. You can read the answers there.
-
Admin about 11 years
-
Admin over 7 yearsOpen in Photoshop and save as PNG
-
-
Raymond over 13 yearsNo more overkill than the 5 or so 'free' programs I installed that left a watermark on the image. Worked beautifully, thanks!
-
Andreas about 12 yearson mac with homebrew I had to install imagemagick and ghostscript for this to work. brew install imagemagick brew install ghostscript
-
Sparhawk about 11 yearsWhy do you prefer the results of pdftoppm? I notice that the default output resolution is higher than imagemagick (although this can be changed), but apart from that they seem comparable on my test file.
-
chrishiestand about 11 yearsGimp works great for a single page, but I don't see a simple way to export lots of pages automatically. I'm sure if you know gimp well you could use automation tools to get it working. But perhaps pdftoppm is better.
-
Brad about 11 years@chrishiestand, You should post that as an alternative answer.
-
maxpenguin about 11 yearsPoppler does a much better job for me - I've got an input pdf with CYMK colours, with imagemagick the colours come out a crazy bright cyan. Also convert takes ~8 seconds and pdftoppm takes less than 0.5 seconds. Thanks for the pointer!
-
galacticninja about 11 years
-
HikeMike almost 11 yearsPaint can open PDFs?
-
Canadian Luke almost 11 years@DanielBeck He's saying to open in a PDF viewer, then copy and paste
-
Roman Protsiuk almost 11 yearsconverting multipage PDF with poppler will look more like this:
pdftoppm -png myfile.pdf myfile
-
sandover over 10 yearsInformally comparing them head to head, I found pdftoppm about 5x (for PNG) to 16x (for JPG) faster once I adjusted for the same resolution. My test file was a scientific paper 10 pages long.
-
kromuchi over 10 yearsSee blog.alivate.com.au/poppler-windows for windows binaries of poppler and use
pdftocairo -png
-
joeA over 9 yearsSigned up for super user just to upvote this. Now if I only had any hope of remembering it...
-
Alain Pannetier over 8 years+1 for inkscape. Because you can edit the pages, rework the diagrams and save as svg or even as pdf etc...
-
Rachael over 8 yearsRoute is "import" -> export as
-
Ajedi32 over 8 yearsNote that if you use imagemagick, you may also need ghostscript: stackoverflow.com/q/32466112/1157054
-
DetlevCM about 8 yearsWhile this is an old post, I think it may be worth pointing out that GIMP is not an ideal solution - at least I remember it not readin a pdf file generated by R correctly. Using pfftoppm with R generated pdf plots produces the correct image. (And Adobe Acrobat 9 Pro works too if you have it - can't speak about other versions.)
-
Noumenon over 7 yearsJust don't make the mistake of trying to actually edit the PNG with GIMP if you know how to use any other image editor. Convert and export.
-
Mr Purple about 7 yearsFor multi page pdfs you can File>Open_as_layers then File>Export_Layers using the export layers as png plugin
-
prakash over 6 yearsAn update may be in order. With the 2.8.16 version of GIMP, I found that "Export as" is used instead of "Save as".
-
goetzc about 5 yearsOn macOS you can also use the build-in
sips
tool:sips -s format png the_pdf_file.pdf --out the_png_file.png
-
Admin about 2 years
attempt to perform an operation not allowed by the security policy
PDF' ` -
Admin about 2 years@Vimos Might be a bug in your version of ghostscript or imagemagick, but see here.