Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)
I want to know how can I efficiently save a specific page in a pdf as a jpeg file?

1 Answer

0 votes
by (108k points)

In your case, the pdf2image library is the best option in Python.

You can install it by the pip:

pip install pdf2image

Once you have installed you can use the following code to get images:

from pdf2image import convert_from_path

pages = convert_from_path('pdf_file', 500)

For saving the pages in jpeg format, you can  refer to the below code:

for page in pages:

    page.save('out.jpg', 'JPEG')

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jan 2, 2021 in Python by laddulakshana (16.4k points)
0 votes
1 answer

Browse Categories

...