Skip to content

Commit

Permalink
Handle rawdates for pdfinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
ldevandiere authored Jul 29, 2020
1 parent ba11f6a commit ce08f3b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions pdf2image/pdf2image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit ce08f3b

Please sign in to comment.