Skip to content

Instantly share code, notes, and snippets.

How to Convert PDF to JPEG in Python. For more details: https://kb.aspose.com/pdf/python/how-to-convert-pdf-to-jpeg-in-python/
import aspose.pdf as pdf
# Set the source PDF directory path
filePath = "C://Words//"
# Set the product license in your application to convert PDF file to JPEG images
pdfToPngLicense = pdf.License()
pdfToPngLicense.set_license(filePath + "Conholdate.Total.Product.Family.lic")
#Access the source PDF file document from the disk
pdfDoc = pdf.Document(filePath + "Output.pdf")
#Instantiate the JPEG devise for rendering
resolution = pdf.devices.Resolution(300)
jpegDevice = pdf.devices.JpegDevice(resolution)
count=1
#for (int pageCount = 1; pageCount <= document.Pages.Count; pageCount++)
for pdfPage in pdfDoc.pages:
#Convert a particular PDF page and save that as JPEG image
jpegDevice.process(pdfPage, filePath+"image"+ str(count) +"_out.jpeg")
count = count + 1
print("JPEG Rendering process completed")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment