Generating Professional PDF Invoices and Quotes from Your Web Application
Business Operations

Generating Professional PDF Invoices and Quotes from Your Web Application

23 February 20264 min readBy Greats Industries

Clients expect polished PDF documents. Building PDF generation into your web application — with your brand, correct VAT, and banking details — is a solvable engineering problem. Here is how we do it.

A professionally designed PDF invoice does more than request payment — it signals that your business is organised, trustworthy, and worth doing business with again. Clients who receive well-formatted documents pay faster and refer more often. Building automated PDF generation into your application is a one-time investment with permanent returns.

The technical options

  • WeasyPrint (Python): converts HTML/CSS to PDF using Cairo. Best for complex layouts with brand styling. Handles Tailwind CSS output with minor tweaks.
  • Puppeteer / Playwright (Node.js): launches a headless Chrome instance and prints to PDF. More resource-intensive but renders pixel-perfect web pages.
  • ReportLab (Python): programmatic PDF generation. Best for data-heavy reports with charts and tables. Steeper learning curve.
  • PDFKit (Node.js): imperative PDF construction. Good for simple documents, less suitable for complex branded layouts.

Our approach: HTML templates → WeasyPrint

For quotations and invoices, we use Jinja2 HTML templates styled with inline CSS (WeasyPrint does not support all Tailwind classes). The template includes: company logo and address block; client address block; quotation/invoice number (GS-2026-0001 format); line items table with quantity, unit price, and line total; subtotal, VAT (14 %), discount, and grand total; payment terms and bank details; footer with registration number and T&Cs.

VAT compliance for Botswana

BURS requires VAT-registered businesses to include: their VAT registration number, the customer's VAT number if applicable, the date, the invoice number, a breakdown showing VAT amount separately from the ex-VAT price, and the rate applied (standard 14 %). Automate this into your template — manual VAT calculations on Word documents are an audit risk.

Delivery options

  • Email attachment: generate on demand and attach to automated email via aiosmtplib (Python async).
  • WhatsApp document: use Infobip or Africa's Talking WhatsApp API to send PDF directly to client phone.
  • Secure download link: store in S3-compatible storage and send a time-limited signed URL.
  • Portal preview: render an HTML version in the portal for quick review before generating the final PDF.
"A polished PDF invoice is a marketing asset. It communicates professionalism every time your client opens it."
Business Operations Back to Blog