Create a PDF with Python

So, you’re doing some data analysis in Python, and you want to generate a PDF report. If you Google around, you’ll find a bunch of jerry-rigged ways of doing it, by generating HTML. Working with HTML and CSS is a pain – wouldn’t it be easier if we could just design our PDFs with a drag-and-drop designer?

We’re going to do just that, using Anvil. Anvil is a platform for building web UIs, but today we’ll just be using it to make PDFs.

In this example, we’re going to take two CSVs, representing sales data from this month and last month, and create a PDF report that looks like this:

We’ll build up to this in a few stages: