amescap.pdf2image

pdf2image is a light wrapper for the poppler-utils tools that can convert PDFs into Pillow images.

Reference: https://github.com/Belval/pdf2image

Third-party Requirements:

  • io

  • tempfile

  • re

  • os

  • subprocess

  • PIL

  • uuid

  • Pillow

Module Contents

Functions

convert_from_bytes(pdf_file[, dpi, output_folder, ...])

Convert PDF to Image will throw an error whenever one of the

convert_from_path(pdf_path[, dpi, output_folder, ...])

Convert PDF to Image will throw an error whenever one of the

convert_from_bytes(pdf_file, dpi=200, output_folder=None, first_page=None, last_page=None, fmt='ppm', thread_count=1, userpw=None, use_cropbox=False)

Convert PDF to Image will throw an error whenever one of the condition is reached

Parameters:
  • pdf_file (float) – Bytes representing the PDF file

  • dpi (int) – image quality in DPI (default 200)

  • output_folder (str) – folder to write the images to (instead of directly in memory)

  • first_page (int) – first page to process

  • last_page (int) – last page to process before stopping

  • fmt (str) – output image format

  • thread_count (int) – how many threads to spawn for processing

  • userpw (str) – PDF password

  • use_cropbox (bool) – use cropbox instead of mediabox

convert_from_path(pdf_path, dpi=200, output_folder=None, first_page=None, last_page=None, fmt='ppm', thread_count=1, userpw=None, use_cropbox=False)

Convert PDF to Image will throw an error whenever one of the conditions is reached.

Parameters:
  • pdf_path (str) – path to the PDF that you want to convert

  • dpi (int) – image quality in DPI (default 200)

  • output_folder (str) – folder to write the images to (instead of directly in memory)

  • first_page (int) – first page to process

  • last_page (int) – last page to process before stopping

  • fmt (str) – output image format

  • thread_count (int) – how many threads to spawn for processing

  • userpw (str) – PDF password

  • use_cropbox (bool) – use cropbox instead of mediabox