Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»General Articles»How to Convert PDF to Image in Linux

    How to Convert PDF to Image in Linux

    RahulBy RahulApril 5, 20212 Mins Read

    In this article you will learn to how to convert a PDF file to Image in Linux command line interface. Pdftoppm converts Portable Document Format (PDF) files to the color image files like PNG, JPG etc. Pdftoppm reads the PDF file and creates one PPM (image) file for each page.

    Before beginning this tutorial, you must have to install below package on your system. Use one of the following commands to install poppler package

    # On Ubuntu/Debian & Linux Mint 
    sudo apt install poppler-utils
    
    # On CentOS/RHEL & Fedora 
    sudo dnf install poppler-utils
    
    # On Arch Linux 
    sudo pacman -S poppler
    

    As you have installed required packages on your system. Let’s start converting pdf file to images via Linux command line.

    Syntax

    A basic syntax to convert a pdf file to image looks like:

    pdftoppm [options] PDF-file image_name
    

    Here:

    • options – Define options like image format -png, -jpeg etc.
    • PDF-file – Input PDF file
    • image_name – Set a name for output images

    1. Convert PDF to Image (all pages)

    I have downloaded a sample pdf file with 5 pages. Then used pdftoppm command to convert PDF to images. It will create a separate image for each pdf page.

    pdftoppm -jpeg Sample.pdf output_file 
    

    You can also change -jpeg with -png to create png files.

    Once the file converted, use ls -l command to list all files in current directory. Here you will see all the images generated from pdf file.

    Convert pdf to image

    2. Convert PDF to Image (Specific Pages)

    Instead of creating images of all pages, you can also convert specific pages only.

    pdftoppm -jpeg -f 2 -l 4 Sample.pdf output_file 
    

    Here -f define the first page to start and -l defines the last page to convert.

    As per the above command, it will create images of pages 2 to 4 only.

    3. Specify PDF Password

    For the password protected pdf files, specify the user password using -upw command line option.

    pdftoppm -jpeg −upw user_password_here Sample.pdf output_file 
    

    Conclusion

    In this tutorial, you have learned to convert PDF to images using Linux command line.

    Use pdftoppm --help command to get more help about this command.

    pdf
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Remove CloudFront Cache
    Next Article How to Install PostgreSQL and pgAdmin4 in Ubuntu 20.04

    Related Posts

    How to Import GPG Keys on Ubuntu & Debian (without apt-key)

    2 Mins Read

    Running a Cron job every Sunday (Weekly)

    2 Mins Read

    Scheduling a Python Script with Crontab

    2 Mins Read

    Running cron job every 12 hours (twice a day)

    Updated:August 2, 20221 Min Read

    (Resolved) Key is stored in legacy trusted.gpg Keyring

    Updated:August 9, 20222 Mins Read

    How to list all collections in MongoDB database

    1 Min Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Import GPG Keys on Ubuntu & Debian (without apt-key)
    • How To Install Google Chrome On macOS
    • How to Install Minecraft on Ubuntu 22.04 & 20.04
    • Running a Cron job every Sunday (Weekly)
    • Running Multiple Commands At Once in Linux
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.