5

I need to convert html text to pdf.

Most answers here recommend to use pdfkit and wkhtmltopdf (https://wkhtmltopdf.org/). However, me company doesn't allow me to install wkhtmltopdf (it is also blocked by admin). There was an option to build from source but it seems like google blocks it due to security reason (https://github.com/wkhtmltopdf/wkhtmltopdf).

Is there an alternative or workaround?

I'm very new to python and don't have programming background, appreciate every detailed explanation.

PoonLamy
  • 101
  • 1
  • 2
  • 4

3 Answers3

5

Yes you can just download it and run it directly. I used that for a shared host (WebFaction) where I have SSH but not root access nor installation option.

cd /tmp
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
cd wkhtmltox/
./bin/wkhtmltopdf

You should be good.

Note that version 0.12.5 is out but has no linux-generic version. Therefore you may want to stick to 0.12.4 for now.

vinyll
  • 11,017
  • 2
  • 48
  • 37
3

For Python, WeasyPrint would be the obvious replacement for wkhtmltopdf. Don't have a lot of experience, personally, however.

frabjous
  • 1,019
  • 9
  • 13
  • This is an old thread, but WeasyPrint from a URL is quite poor. It does not support current CSS websites producing very poor results. – Gmck Oct 13 '21 at 19:01
-1

I recomend you to create a PDF on user browser with pdfmake.

Good luck!

stefo91
  • 618
  • 6
  • 16