I'm attempting to use Python to convert a multi-page PDF into a series of JPEGs. I can split the PDF up into individual pages easily enough with available tools, but I haven't been able to find anything that can covert PDFs to images.
PIL does not work, as it can't read PDFs. The two options I've found are using either GhostScript or ImageMagick through the shell. This is not a viable option for me, since this program needs to be cross-platform, and I can't be sure either of those programs will be available on the machines it will be installed and used on.
Are there any Python libraries out there that can do this?
Open your PDF in Adobe Acrobat Pro and choose file. Export it to the new file format by going to the right pane and choosing “Export PDF” tool. Or, go to the menu and select “File” > “Export to” > “Image.” Choose image format type (e.g., JPG file, TIFF, etc.).
Just replace from pyPdf import ... with from PyPDF2 import ... . User with open("document-page%s. pdf" % (i+1), "wb") as outputStream: if you want your files to be named with index starting from 1 instead of 0. If i want to split 100 instead of split 1 page individual i want to save 2 in 1 pdf.
ImageMagick has Python bindings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With