13.5 C
Texas

how to convert PDF to images with pdftoppm

On certain occasions, users need to move a pdf to an image, for various reasons. In these cases, they should use programs or pages that facilitate this conversion. However, for this first month of the year, they will explain how to convert a pdf to images. For GNU/Linux systems, using the pdftoppm tool.

Pdftoppm is a tool that allows you to convert pages of a pdf file to image formats. As would be the case with JPG, PNG among others, it is also a command-line tool. That is, with pdftoppm the user can convert complete pdf documents to separate images. In addition, it allows you to specify the resolution of preferred images, and to scale and crop your images.

How to convert pdf files to images with pdftoppm

The first thing you need, to use the command line pdftoppm is to install it. You must install the package as follows depending on the distribution:

For Debian, Ubuntu, Linux Mint and similar distributions, the following command is used:

- Advertisement -
sudo apt install poppler-utils

In RHEL, Centos or Fedora systems

sudo dnf install poppler-utils

On SUSE and OpenSuse

sudo zypper install poppler-tools

Finally, for systems like Arch and similar:

sudo pacman -S poppler

Once the installation is done, the user can start converting.

Convert PDF documents to image

As mentioned above, once the installation is complete, you can now convert. The usage syntax is as follows:

pdftoppm -( image_format) (pdf_file) (image_name)

Now we will proceed to show an example, the name is Mathematics_Examples.pdf will be converted to JPG format, under the name of Mathematics_example.

pdftoppm -jpg Mathematics_Examples.pdf Mathematics_example

When the command is executed, each page will be converted into images in JPG format.

Convert range of PDF pages to images.

The syntax for specifying the range is as follows:

pdftoppm -( image_format) -f N -l N (pdf_name) (image_name)

Where N means the number of the first page, to convert and -l N for the last page to convert.

For the following example, we will proceed to convert pages 5 to 10 of example_mathematics.pdf to JPG.

pdftoppm -jpg -f 5 -l 10 Example_mathematics.pdf Mathematics_example

Adjusting the quality of the conversion

It has been explained how to convert pdf documents to images, but in pdftoppm it converts PDF pages to images with a default DPI of 150. Similarly, to adjust, the user must use the number “rx” which specifies resolution X, and “-ry” the number which specifies resolution Y, in DPI.

For example:

pdftoppm -jpg -rx 300 -ry 300 Example_mathematics.pdf Mathematics_example

This way we indicate that the image will be 300×300 and in JPG format.

To consult, you can read the source. Click here.

Conclusion

Before the end of the first month of 2021, with a small tutorial to convert pdf documents to images. Through command lines, using the pdftoppm tool. Where the installation package, is available for the vast majority of the various Linux distributions.

To know more about the news and the turorials related to Linux. We invite you to read our section on Linux.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article