Search code examples
pythonpython-2.7pdfpdf-generationweasyprint

How to render links with weasyprint?


from weasyprint import HTML
HTML(string='<a href="http://google.com">link</a>').write_pdf('tmp.pdf')

Doesn't have clickable link inside it.

I'm scraping a part of the site as HTML and tryting to render that part. Maybe that is the problem. But I don't have full valid HTML. Does it mean that I can't render proper PDF using weasyprint?

The above example will have clickable link using xhtml2pdf. Is there any way to make it work with weasyprint?


Solution

  • This is a bug in WeasyPrint 0.17 and possibly some previous versions. See https://github.com/Kozea/WeasyPrint/issues/42