Merge pull request #7409 from surajshetty3416/fix-pdf

fix(pdf): Define filedata before it is used
This commit is contained in:
Suraj Shetty 2019-05-05 13:44:59 +05:30 committed by GitHub
commit 4e82a2edf5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,12 +18,14 @@ def get_pdf(html, options=None, output=None):
"disable-local-file-access": "",
})
filedata = ''
try:
# Set filename property to false, so no file is actually created
filedata = pdfkit.from_string(html, False, options=options or {})
# https://pythonhosted.org/PyPDF2/PdfFileReader.html
# create in-memory binary streams from filedata and create a PdfFileReader objcet
# create in-memory binary streams from filedata and create a PdfFileReader object
reader = PdfFileReader(io.BytesIO(filedata))
except IOError as e: