Pdftoppm, convert PDF files into images from Ubuntu

about pdftoppm

In the next article we are going to take a look at pdftoppm. This is a free and open source command line utility for Gnu / Linux. With it you can easily generate image files from a PDF document. It will also allow us to configure the file format and the dimensions of the output images, among other things. We will find this tool in the package poppler-utils.

If as a user you find yourself needing to save a specific page of a document file as an image, to use it as a reference later. With the pdftoppm utility, image files can be generated very easily from a PDF document, using just one command in the terminal.

Pdftoppm not only allows us to convert PDF into image files, it will also give us the possibility to choose the format and dimensions of the images to be generated, we can even add a color filter. Among the output image formats for conversion that this tool allows, we can find; PNG, JPEG, JPEGCMYK, JPEGOPT and TIFF.

Install pdftoppm Ubuntu

As I mentioned earlier, this tool is in the poppler-utils package. If you don’t have this package already installed on your Ubuntu system, you can open a terminal (Ctrl + Alt + T) and run the following script to proceed with its installation:

install poppler utils

sudo apt update; sudo apt install poppler-utils

How to convert PDF files to images

Pdftoppm offers many options for use, but the most common are; convert the first page of a PDF to an image, convert an entire PDF to images, change the image format, convert only specific pages of the pdf, and change the resolution of the resulting image.

You can convert a PDF to images using the syntax:

pdftoppm -formato documento nombre-imagen
  • Format → is the extension of the output image file.
  • document → is the path to the PDF file that we are going to convert.
  • image-name → is the name of the output image.

Convert the first PDF page to an image

In order to convert the first page of a PDF file to a png image, thanks to the options -F Y -l, we will only need to use a command like the following:

get first page image

pdftoppm -png -f 1 -l 1 ejemplo.pdf ImagenPrimeraPagina

Convert an entire PDF to images

The following command will transform the entire PDF file page by page into .png files. If the document has multiple pages, pdftoppm will add numbers to the filename, (p. Eg image-1.png and image-2.png) while checking out image files.

convert an entire pdf into images

pdftoppm -png ejemplo.pdf imagen

Specify a range of pages of the pdf to convert to images

With the options -F Y -l that we used in the first example, we can also specify a wider range of pages in the PDF file to convert to images. In the following example we are going to pass the range from 2 to 5, to convert from page two to five into images, both included.

conversion range with pdftoppm

pdftoppm -png -f 2 -l 5 ejemplo.pdf imagen

Modify the quality of the output images

With the options -rx Y -ry resolution can be modified dpi of the images to be generated. By default, the pdftoppm tool generates the output images with a resolution of 150 dpi, and in this example we are going to lower it to 75 dpi.

dpi reduction

pdftoppm -png -rx 75 -ry 75 ejemplo.pdf imagen

Adjust the colors of the output images

This tool will also allow us to add color filters to the output images. Simply we will need to replace the image format with the filter name. You can convert the PDF to grayscale images by adding the option -gray. The generated file will have the extension PGM.

add color filter to images with pdftoppm

pdftoppm -gray ejemplo.pdf imagen


In order to get full details on how to use this tool, the users can resort to the help that can be consulted with the command:

pdftoppm help

pdftoppm --help

They can also be consult the man pages with the command:

man pdftoppm

Pdftoppm is a reliable tool if you are interested in converting a PDF document into images. The utility offers control over the configuration of the extension, name and resolution of the resulting image, using a single command from the terminal.

Add Comment