From ce08f3bed55849c5b1e1126ad078bccf55e8347c Mon Sep 17 00:00:00 2001 From: ldevandiere <37556870+ldevandiere@users.noreply.github.com> Date: Tue, 28 Jul 2020 19:15:21 -0500 Subject: [PATCH] Handle rawdates for pdfinfo --- pdf2image/pdf2image.py | 9 ++++++--- setup.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pdf2image/pdf2image.py b/pdf2image/pdf2image.py index f71c6fe..8eda6cb 100644 --- a/pdf2image/pdf2image.py +++ b/pdf2image/pdf2image.py @@ -406,13 +406,16 @@ def _get_poppler_version(command, poppler_path=None): return 17 -def pdfinfo_from_path(pdf_path, userpw=None, poppler_path=None): +def pdfinfo_from_path(pdf_path, userpw=None, poppler_path=None, rawdates=False): try: command = [_get_command_path("pdfinfo", poppler_path), pdf_path] if userpw is not None: command.extend(["-upw", userpw]) + if rawdates: + command.extend(["-rawdates"]) + # Add poppler path to LD_LIBRARY_PATH env = os.environ.copy() if poppler_path is not None: @@ -447,13 +450,13 @@ def pdfinfo_from_path(pdf_path, userpw=None, poppler_path=None): ) -def pdfinfo_from_bytes(pdf_file): +def pdfinfo_from_bytes(pdf_file, userpw=None, rawdates=False): fh, temp_filename = tempfile.mkstemp() try: with open(temp_filename, "wb") as f: f.write(pdf_file) f.flush() - return pdfinfo_from_path(temp_filename) + return pdfinfo_from_path(temp_filename, userpw=userpw, rawdates=rawdates) finally: os.close(fh) os.remove(temp_filename) diff --git a/setup.py b/setup.py index 46028bc..a860388 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="pdf2image", - version="1.13.1", + version="1.14.0", description="A wrapper around the pdftoppm and pdftocairo command line tools to convert PDF to a PIL Image list.", long_description=long_description, long_description_content_type="text/markdown",