Generating PDFs in code is difficult. Many solutions revolve around unfamiliar proprietary APIs that require pixel perfect placement of text and images that can become a nightmare in the long run.
This tutorial uses HTML, CSS, and Go to achieve a lightweight, modern approach to dynamically creating and serving PDFs from an API endpoint.
This tutorial follows how our team replaced our exsting PDF generation system. The decision for us to use wkhtmltopdf was primarily driven by our use of Golang on the backend and the
allure of keeping our services as small as possible.
I recognize some teams may be interested in a Chromium/Puppeteer approach to PDF's and I've linked some helpful articles to get you started.
You can checkout the template golang + go-wkhtmltopdf project if you'd like to skip straight to code.