Spaces:
Running
Running
File size: 495 Bytes
10889be |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import os
from pdf2image import convert_from_path
# Set the PDF file path
pdf_path = 'test.pdf'
# Convert the first page of the PDF to a JPEG image
first = 14
last = 14
images = convert_from_path(pdf_path, dpi=300, first_page=first, last_page=last, poppler_path=r"C:\poppler-23.07.0\Library\bin")
# Save the image file
image_path = os.path.splitext(pdf_path)[0]
for index, image in enumerate(images):
image.save(image_path + "p" + str(index+first) + '.jpg', 'JPEG') |