We’ll be using Jinja2 to generate HTML files of our reports that we will convert into PDFs with other tools. You can think of it like super high-powered string substitution. It’s a very flexible tool, used widely in Python web applications to generate HTML for users. In short, it lets you automatically generate text documents by programmatically filling in placeholder values that you assign to text file templates. Jinja2 is a great tool to become familiar with, especially if you do web development in Python. Note that you also need to install a tool called wkhtmltopdf for pdfkit to work. We’ll install our required packages with the following commands: pip install pdfkit pip install Jinja2 The particular solution I came up with uses two main tools: Jinja2 and Pdfkit.
#PYTHON PDFKIT DISPLAYS COLUMNS PDF#
I recently needed to do PDF reporting in a work assignment. This is often important for getting buy-in from people comfortable with the old system. This means that if the legacy system used PDF reporting, then you should strongly consider creating this functionality in the replacement system. You need to match existing reporting formats: If you’re replacing a legacy reporting system, it’s often a good idea to try to match existing reporting methods as your first step.
People often want “hard copies” of particular reports they are running and don’t want to reproduce everything they did in an interactive dashboard.