try to decrypt pdf with empty password if its encrypted

This commit is contained in:
j 2014-10-31 16:13:02 +01:00
parent 9304d14c5f
commit c6c8e0dc8a

View file

@ -101,12 +101,14 @@ def info(pdf):
try: try:
pdfreader = PdfFileReader(fd) pdfreader = PdfFileReader(fd)
data['pages'] = pdfreader.numPages data['pages'] = pdfreader.numPages
if pdfreader.getIsEncrypted():
pdfreader.decrypt('')
info = pdfreader.getDocumentInfo() info = pdfreader.getDocumentInfo()
if info: if info:
for key in info: for key in info:
if info[key]: if info[key]:
data[key[1:].lower()] = info[key] data[key[1:].lower()] = info[key]
xmp =pdfreader.getXmpMetadata() xmp = pdfreader.getXmpMetadata()
if xmp: if xmp:
for key in dir(xmp): for key in dir(xmp):
if key.startswith('dc_'): if key.startswith('dc_'):