Installing wkhtmltopdf on Python 3.6 Alpine
Asked Answered
I

2

6

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.

Incision answered 11/6, 2019 at 13:49 Comment(5)
It has a alpine package: pkgs.alpinelinux.org/package/edge/community/x86/wkhtmltopdfPedo
Install it inside your DockerfilePedo
you mean apk add wkhtmltopdf?Incision
Yes. Have you tried it ?Pedo
this question may become relevant again, because wkhtmltopdf is not available in the Alpine 3.15 repository (released 2021-11)Whirlybird
C
8

You might need wkhtmltopdf and xvfb to run on a server:

apk add wkhtmltopdf xvfb
Communistic answered 8/6, 2020 at 13:7 Comment(1)
You can also add fonts apk add fontconfig freetype ttf-dejavu ttf-droid ttf-freefont ttf-liberation ttf-ubuntu-font-familyZuckerman
H
1

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)
Hartill answered 13/4, 2021 at 7:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.