JoshData / pdf-redactor

A general purpose PDF text-layer redaction tool for Python 2/3.
Creative Commons Zero v1.0 Universal
184 stars 61 forks source link

Missing metadata isn't handled. #18

Open djaychela opened 5 years ago

djaychela commented 5 years ago

When applying the example.py script to some PDF files, I've been getting errors -

"Title": [lambda value: value.upper()], AttributeError: 'NoneType' object has no attribute 'upper'

I've found what I think is a simple fix for this - checking if the value is None in line 155 of pdf_redactor.py:

# Filter the value. if value is not None: value = f(value)

Not sure about the etiquette of submitting a PR, but would like to do so - this has fixed the issues I've had when working on a number of PDFs using redactor.

JoshData commented 5 years ago

Hi. I appreciate you hunting down your issue.

But the change would change the functionality of the library. I'd suggest changing your lambda function instead to e.g. value.upper() if value else None.