Skip to content
Snippets Groups Projects

Convertir un pdf en images avec Python

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Gregory.Ooghe

    Programme transformant un fichier pdf en images (une par page).

    pdf_to_image.py 740 B
    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/
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment