Convertir un pdf en images avec Python
The snippet can be accessed without any authentication.
Authored by
Gregory.Ooghe
Programme transformant un fichier pdf en images (une par page).
from pdf2image import convert_from_path
from pdf2image.exceptions import (
PDFInfoNotInstalledError,
PDFPageCountError,
PDFSyntaxError)
wd = r"C:\Users\gregory.ooghe\Documents\Travail\400_Programmation"
pdf_location = wd + "\git\SCEP_intro_git_2020.pdf"
images = convert_from_path(pdf_location,
size=(1200, None))
count = 0
for img in images:
img.save(wd + "\git\pdf_image\im_" + str(count) + ".jpg", 'JPEG')
count = count + 1
# poppler_path = wd + "\Python_poppler\Release-20.10.0\poppler-\bin" as an argument in convert_from_path
# liens utiles :
# https://pypi.org/project/pdf2image/
# https://www.geeksforgeeks.org/convert-pdf-to-image-using-python/
Please register or sign in to comment