How to convert a PDF file to a PNG image with Ubuntu
There can be times when it is needed to change a PDF file into a PNG image. For instance, yesterday I had to send a text message with a copy of a receipt that I had. The receipt was in PDF format and my phone can't send a PDF file as a text message.
So I looked for an easy way to convert the PDF file into a PNG image which I'd be able to send as an MMS message. The simple one line command to do this is shown below....
pdftoppm fileyouwanttoconvert.pdf outputfilename -png
So yeah, if you wanted to convert a pdf file to a png that's all you'd have to do.
There's more options though. If you just want to convert just one page of a multi-page PDF file to a PNG image, then you could run the following:
pdftoppm fileyouwanttoconvert.pdf outputfilename -png -f 15 -singlefile
In that example you'd replace "15" with the page number of the PDF file that you want to convert. For example, if you wanted to change page 3 of a PDF file to a PNG, then you'd simply replace the "15" in the command above with a "3".
Also if you wanted to print a range of pages from your PDF. Like if you only wanted to print pages 3 through 7 of a multi-page PDF, then run the following:
pdftoppm fileyouwanttoconvert.pdf outputfilename -png -f 3 -l 7
If you notice the (-f) and the (-l) options there those just mean "firstpage (-f)" and "lastpage (-l)". So that's why the "3" and the "7" appear respectively after those options.
Using pdftoppm was an easy solution for me because the pdftoppm command was already installed on my Ubuntu system. If that solution doesn't work for you and you want to find another PDF to PNG conversion method, you can go to where I found the above command method at https://askubuntu.com/questions/50170/how-to-convert-pdf-to-image