Reportlab, Weasy, Wkhtml - oh my! Which PDF/Printing plugin to use?

I am seeking to have a template of mine able to be printed with sensible defaults.

I need to print a table, some images and a footer.

The Django Docs suggest Reportlab - but it seems that the Reportlab docs are not Django specific.

django-wkhtmltopdf seems pretty easy - but can it handle footers ok?

There are so many choices in this space and I don’t want to get in issues.

What printing/pdf plugin do you use?

I’ve used Reportlab at both my current employer and my previous employer. Both businesses are heavy Django users.

In my experience, Reportlab is somewhat clunky in usage, but it has a rich feature set. For instance, my last job produced PDFs that ultimately went to an actual print shop for publication. Reportlab had all the features needed to produce the high quality inputs to the printing process.

I can’t speak to other PDF packages that you might want to use.

I’d recommend trying out Reportlab as an experiment outside of your Django project to see how quickly you could produce something to your liking.

1 Like

Thanks @mblayman that is good advice - I’ll try that!

We use both ReportLab and django-wkhtmltopdf, and I think the latter is worth the setup effort for your use case.

You have the advantage of being able to run javascript and use css + html for layout. ReportLab works in a very different way.

The javascript is a bit of a pain to debug though, and you’ll need to run collectstatic in your development environment in order for the static assets linked in the template you’re rendering to be found by the headless browser wkhtmltopdf uses.

A useful tip for debugging is to set up views that allow you to see the exact same html, css, js you are passing to wkhtmltopdf in your browser. That has saved us a ton of time.

1 Like

Thanks! I’ll check that out too!

Down the rabbit hole I go!

What did you finally decide andyide ? I’m on Django 4.2.5 now and need to generate a PDF report - not using a rendered view but just create a PDF from HTML code and email the PDF.

I ended up using weasy print. But I had trouble with the SSL in pulling in images.

In the end (is been 4 years) I realised my customers just wanted to print stuff - so I just render the HTML now.

I dont need to email pdfs.

So yeah - I dont need to do it now - sorry I cant be of more help!

1 Like