How to Convert PDF to Image in Linux Command Line

How to Convert PDF to Image in Linux Command Line

pdftoppm converts PDF document pages to image formats like PNG, and others. It is a command-line tool that can convert an entire PDF document into separate image files. With pdftoppm, you can specify the preferred image resolution, scale, and crop your images.

To use the pdftoppm command-line tool, you need to first install pdftoppm which is a part of the poppler / poppler-utils / poppler-tools package. Install this package as follows depending on your Linux distribution

$ sudo apt install poppler-utils     [On Debian/Ubuntu & Mint]
$ sudo dnf install poppler-utils     [On RHEL/CentOS & Fedora]
$ sudo zypper install poppler-tools  [On OpenSUSE]  
$ sudo pacman -S poppler             [On Arch Linux]

Below are examples of how you can use the pdftoppm tool to convert your pdf files to images:

1. Convert PDF Document to Image

The syntax for converting an entire pdf is as follows:

$ pdftoppm -  
$ pdftoppm -  

In the example below, the name of my document is Linux_For_Beginners.pdf and we will convert it to PNG format and name the images as Linux_For_Beginners.

$ pdftoppm -png Linux_For_Beginners.pdf Linux_For_Beginners

Each page of the PDF will be converted to PNG as Linux_For_Beginners-1.png, Linux_For_Beginners-2.png, etc.

Convert PDF to Images in Linux Commandline

Convert PDF to Images in Linux Commandline

2. Convert Range of PDF Pages to Images

The syntax for specifying range is as follows:

$ pdftoppm - -f N -l N  
$ pdftoppm - -f N -l N  

Where N specifies the first-page number to covert and -l N for the last page to convert.

In the example below, we will convert pages 10 to 15 from Linux_For_Beginners.pdf to PNG.

$ pdftoppm -png -f 10 -l 15 Linux_For_Beginners.pdf Linux_For_Beginners

The output will be images named Linux_For_Beginners-10.png, Linux_For_Beginners-11.png, etc.

Convert Range PDF Pages to Image

Convert Range PDF Pages to Image

3. Convert First PDF Page to Image

To convert the first page only use the syntax below:

$ pdftoppm -png -f 1 -l 1 Linux_For_Beginners.pdf Linux_For_Beginners

4. Adjust DPI Quality to Conversion

Pdftoppm converts PDF pages to images with a DPI of 150 by default. To adjust, use the rx number which specifies the X resolution, and -ry the number which specifies the Y resolution, in DPI.

In this example, we adjust the DP quality of Linux_For_Beginners.pdf to 300.

$ pdftoppm -png -rx 300 -ry 300 Linux_For_Beginners.pdf Linux_For_Beginners

To see all the choices available and supported in pdftoppm, run the commands:

$ pdftoppm --help  
$ man pdftoppm

Hopefully, you can now convert your PDF pages to images in Linux using the Pdftoppm command-line tool.


Our trusted sources

We only publish news from well-known cybercrime magazines via RSS. You will find here everything about hackers & cybercrime. Also you can visit the direct sources from us.

Just click on one of the buttons.


Check out our Guidebook page.  And read everything about it.  Also how to protect yourself from hacker attacks.  An all in one thing.