Methods to Convert a PDF File to an Picture in Linux With pdftoppm

Do you want to convert a PDF file to images on Linux? Sometimes you may need to save a specific page of a document file as an image for future reference. Online tools don't offer much choice when it comes to converting PDF files to images.

You can easily create image files from a PDF document using the pdftoppm utility. And the best part is that you can type a simple command on the terminal. In this article, we are going to explain pdftoppm in detail and provide guidance on how to use this tool efficiently.

What is pdftoppm?

As mentioned above, pdftoppm is a command line Linux utility that converts PDF documents to image files. With pdftoppm you can configure the format and dimensions of the output images. The tool also allows you to add a color filter, such as grayscale, to the images.

Pdftoppm is part of the Poppler utensils Package on Linux. You will not find this package pre-installed in any Linux distribution, so you will have to install it manually.

How to install that Poppler utensils Package on Debian-based distributions:

sudo apt install poppler-utils

On Arch Linux:

sudo pacman -S poppler

You can install Poppler utensils under CentOS and Fedora with DNF or Yum:

sudo yum install poppler-utils
sudo dnf install poppler-utils

Using pdftoppm

The pdftoppm utility has a number of options that you can use. The most basic are converting a PDF file to images, changing the image format, converting only certain pages, and changing the image resolution.

Basic syntax

The basic syntax of the tool is:

pdftoppm -imageformat document imagename

…Where Image format is the file extension that the output images should have. document is the path to the PDF file and Image name is the name of the output image.

Convert the entire PDF file to images

To convert a PDF file to images easily:

pdftoppm -png test-document.pdf output images

The above command converts the pages of the document into images. If the document has multiple pages, pdftoppm appends numbers to the name of the output file, e.g. Output images-1 and output images-2.

You can also use the to change the character separator between the output name and the extension -sep Flag. For example to use Question mark ((?) as a separator:

pdftoppm -png -sep? test-document.pdf output images

Change the picture extension

To change the format of the output files, change the file extension in the command. How to convert the document to JPEG Files:

pdftoppm -jpeg test-document.pdf output images

Pdftoppm supports the following output formats:

  • PNG

  • JPEG

  • JPEGCMYK

  • JPEGOPT

  • TIFF

If you do not specify a format, the tool generates the images with the PPM Extension by default.

Convert a range of pages to images

If you only want to convert a specific range of pages in the document, use the option -f and -l Flags. The -f and -l stands for first and latest respectively.

pdftoppm -png -f 4 -l 7 test-document.pdf output images

The above command will only convert pages 4 through 7 to images.

To convert only the first page of a PDF:

pdftoppm -png -f 1 -l 1 test-document.pdf output images

Configure the DPI quality of the images

You can also use pdftoppm to change the DPI of the images. DPI stands for Points per inch and refers to the resolution of an image. By default, the tool generates images at a DPI of 150, but you can also specify a custom number for pdftoppm.

You can use the … -rx and -ry Flags to configure the DPI quality of the output images.

pdftoppm -png -rx 200 -ry 200 test-document.pdf output images

Adjust the colors of the output images

To add color filters to the output images, all you need to do is replace the image format with the filter name.

You can use the to convert the PDF file to grayscale images -Gray Flag. The generated file has the PGM Extension.

pdftoppm -gray test-document.pdf output images

How to create monochrome images with pdftoppm:

pdftoppm -mono test-document.pdf output images

Convert password protected PDF files

Use the to convert password protected PDF files with pdftoppm -opw and -upw Flags. The -opw and -upw Flags stand for Owner password and User password respectively.

pdftoppm -png -opw password protected-document.pdf output images
pdftoppm -png -upw password protected-document.pdf output images

Make sure to replace password with the password of the PDF document.

Quickly convert PDF to images on Linux

Pdftoppm is a reliable tool when you want to convert a PDF document to images. The utility allows you to configure the image extension, name, and resolution. And the ability to do all of this directly from the Linux terminal is a crowning glory.

There are several PDF editors for Linux that give you various tools to modify documents efficiently. You can also easily extract images from a PDF document if you need to.

How to extract images from PDF file and use them anywhere

Here are the easiest ways to extract a single image or multiple images from a PDF file and save them on your desktop.

Continue reading

About the author

Deepesh Sharma
(53 articles published)

Deepesh is the junior editor for Linux at MUO. He has been writing informational content on the Internet for over 3 years. In his spare time he enjoys writing, listening to music and playing the guitar.

More
From Deepesh Sharma

Subscribe to our newsletter

Sign up for our newsletter to receive tech tips, reviews, free e-books, and exclusive offers!

One more step …!

Please confirm your email address in the email we just sent you.

Leave a Reply

Your email address will not be published. Required fields are marked *