Has anyone been able to install wkhtmltopdf on python:3.6.0-alpine.
I have tried all the solutions present on the internet. I need to use pdfkit which internally uses wkhtmltopython to convert html to pdf.
Has anyone been able to install wkhtmltopdf on python:3.6.0-alpine.
I have tried all the solutions present on the internet. I need to use pdfkit which internally uses wkhtmltopython to convert html to pdf.
You might need wkhtmltopdf and xvfb to run on a server:
apk add wkhtmltopdf xvfb
apk add fontconfig freetype ttf-dejavu ttf-droid ttf-freefont ttf-liberation ttf-ubuntu-font-family
–
Zuckerman In case someone would like to have the full line that needs to be added to the Dockerfile:
RUN apk update && apk add wkhtmltopdf
or:
RUN apt-get update && apt-get install -y wkhtmltopdf
You can then use the following code in your "Dockerized" Python script:
import pdfkit
path_wkhtmltopdf = '/usr/bin/wkhtmltopdf'
config = pdfkit.configuration(wkhtmltopdf=path_wkhtmltopdf)
pdfkit.from_string(html, '<direction/of/the/report.pdf>', configuration=config)
© 2022 - 2024 — McMap. All rights reserved.
Dockerfile
– Pedo