Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Convert PDF to Image in Linux Command Line - DesignLinux

Jan 01 2021
designlinux 0 Comments

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.

Related Read: 8 Best PDF Document Viewers for Linux Systems

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.

Related

Tags: commandline tools, Fedora Tips, Ubuntu Tips

How to Install Python 3.9 on CentOS 8

Prev Post

How to Install PHP 8 on Debian 10

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 0
  • 606
  • 1,055,378

DesignLinux.com © All rights reserved

Go to mobile version