python-pdfkit icon indicating copy to clipboard operation
python-pdfkit copied to clipboard

OS Error

Open saisiva249 opened this issue 3 years ago • 0 comments
trafficstars

I have deployed my flask in docker

FROM python:3.8
    
RUN   mkdir  /app
COPY  .  /app/
WORKDIR  /app/
RUN  pip3 install  -r requirements.txt 

EXPOSE 5000

ENTRYPOINT [ "python3" ]
CMD [ "app.py" ]

in my requirements

flask
wkhtmltopdf
pdfkit

in my app.py

from flask import Flask
from io import BytesIO
from flask import Flask, request, make_response
import pdfkit

app = Flask(__name__)

@app.route("/", methods=['POST'])
def get_pdf():
  data = request.get_json()
  html = data["html"]
  pdf = pdfkit.from_string(html)
  bytes_file = BytesIO(pdf)
  response = make_response(bytes_file)
  response.headers['Content-Type'] = 'application/pdf'
  response.headers['Content-Disposition'] = \
      'inline; filename=%s.pdf' % 'yourfilename'
  return response


if __name__ == "__main__":
    app.run(debug=True,host='0.0.0.0', port=5000)

Iam getting an error like this.

OSError: No wkhtmltopdf executable found: "b''"
If this file exists please check that this process can read it or you can pass path to it manually in method call, check README. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf

please help in solving, Thanks in advance

saisiva249 avatar Nov 18 '22 14:11 saisiva249