Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

network error: ProtocolUnknownError while converting a local html file #232

Open
ankur0101 opened this issue Jul 18, 2022 · 1 comment
Open

Comments

@ankur0101
Copy link

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

@BenjaminHoegh
Copy link

i have this issue too and enable-local-file-access didn't help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants