fix: Define filedata before it is used

This commit is contained in:
Suraj Shetty 2019-05-05 12:23:46 +05:30
parent beb8b0bcbd
commit d67bcd2212

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: