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.
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>
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.
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.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
#Convert #PDF #Image #Linux #Command #Line