Merge pull request #7409 from surajshetty3416/fix-pdf
fix(pdf): Define filedata before it is used
This commit is contained in:
commit
4e82a2edf5
1 changed files with 3 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue