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.

Two small things before you go

If something didn’t work on your setup, leave a comment and tell me which distro and version you’re on. I read every one, and most of these articles got better because a reader pointed out what was missing.

And if it did work, share it. TecMint has stayed free for 14 years because people pass these articles around, and that traffic is what pays for writing the next one.

Leave a comment
Get two free Linux courses

Learn the Linux basics with two free courses and join 34,000+ readers getting practical TecMint tutorials and selected Pro TecMint articles every week.

Pro TecMint
Get lifetime access for $99

If you want to go beyond the free tutorials, Pro gives you 18 courses, 5 ebooks, and every future course I add. One payment, lifetime access, no renewals.

Winnie Ondara
Winnie Ondara
Contributor
About the author

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.

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.

    Reply

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.