I use pdfkit and wkhtmltopdf to create pdf documents. When I create the first pdf, everything is fine. When I quickly generate another one (within 5 seconds), I get an error [Errno 9] Bad file descriptor. If I close the error (return to the browser) and open again, it will create a pdf file.
my views.py
config = pdfkit.configuration(wkhtmltopdf='C:/wkhtmltopdf/bin/wkhtmltopdf.exe') pdfgen = pdfkit.from_url(url, printname, configuration=config) pdf = open(printname, 'rb') response = HttpResponse(pdf.read()) response['Content-Type'] = 'application/pdf' response['Content-disposition'] = 'attachment ; filename =' + filename pdf.close() return response
Perhaps it is important to note: I am running this site on IIS8, there is no error when starting from the command line (python manage.py runningerver).
Any advice on how to deal with this error would be great.
python django iis pdfkit
phicon
source share