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 -<image_format> <pdf_filename> <image_name>
$ pdftoppm -<image_format> <pdf_filename> <image_name>

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 -<image_format> -f N -l N <pdf_filename> <image_name>
$ pdftoppm -<image_format> -f N -l N <pdf_filename> <image_name>

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.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Winnie Ondara
My name is Winnie, a Linux enthusiast and passionate tech writer in Linux and DevOPs topics. I enjoy keeping abreast with the latest technologies in the Linux ecosystem and trying out new tools provided by the FOSS community.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

1 Comment

Leave a Reply
  1. From text to hyperlinks, from images to graphics, a variety of non-text elements can be included in a PDF. Images and graphics make your document visually more pleasing.


Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.