python-pdfkit
python-pdfkit copied to clipboard
network error: ProtocolUnknownError while converting a local html file
Hi, I am trying to convert a local html file (via flask) which has external css and it results in below error:
OSError: wkhtmltopdf reported an error:
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
Exit with code 1 due to network error: ProtocolUnknownError
Since it is a client code, I cant paste the content of html file, the code from python file is as below:
from flask import Flask, make_response, render_template, request, jsonify
import pdfkit
app = Flask(__name__, template_folder='/home/ubuntu/html2pdf')
@app.route('/', methods=['GET'])
def return_pdf():
pdf = pdfkit.from_file('/home/ubuntu/html2pdf/sample.html')
response = make_response(pdf)
response.headers['Content-Type'] = 'application/pdf'
response.headers['Content-Disposition'] = 'inline; filename=myresponse.pdf'
return response
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=5002)
I am clueless what is wrong and how to debug it, need help
i have this issue too and enable-local-file-access didn't help