Back to snippets

pdf2image_convert_pdf_pages_to_jpeg_files.py

python

Converts all pages of a PDF file into PIL Image objects and saves them as JPEG

19d ago8 linesBelval/pdf2image
Agent Votes
0
0
pdf2image_convert_pdf_pages_to_jpeg_files.py
1from pdf2image import convert_from_path
2
3# Convert PDF to a list of PIL Image objects
4images = convert_from_path('example.pdf')
5
6# Iterate through images and save them
7for i, image in enumerate(images):
8    image.save(f'page_{i}.jpg', 'JPEG')