Generating PDF is a very common task in web development. They are used for a variety of purposes such are reporting, invoice generation and accounting purposes, etc.

In Django, there is this package xhtml2pdf through which we can generate pdf. In this post you’ll be covering three main topics those are generating PDF from HTML and saving as PDF file in the directory, generating PDF from a template by passing context data and saving as PDF file in a directory, rendering PDF from a template in the browser.

Installation and Configuration of xhtml2pdf Package

Enter below command in terminal.

pip install xhtml2pdf

If you want to install the latest version for Python 3 then go with below command

pip install --pre xhtml2pdf

#django #pdf #html #python #developer

How to Convert HTML into PDF with Django
68.85 GEEK