PDF Generator

Create dynamic, high-quality PDFs using Next.js and Puppeteer

About

A Next.js application that generates PDFs from HTML templates using dynamic data and Puppeteer. This project provides a modular approach to PDF generation with reusable components and flexible template system. Built-in Sentry integration enables error monitoring and tracking by project/client in production.

How to Get Started

Example API Request

Here’s an example of how to generate a PDF via curl:

curl -X POST https://pdf-generator.3dconfig.io/api/template-pdf   -H "Content-Type: application/json"   -d '{
	"appID": "1234567890",
    "templateId": "invoice",
	"theme:"
	@import url("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Manrope:wght@200..800&family=Work+Sans:ital,wght@0,100..900;1,100..900&display=swap");
		:root {

		--primary: #436414;
		--primary-light: #e7f6d2;
		--primary-lightest: #EFF4EC;
		--primary-dark: #23350d;
		--gray: #474747;
		--gray-light: #E5E5E5;
		--gray-lightest: #f5f5f5;
		--border-radius: 0.25rem;
		--font-primary: "Inter", sans-serif;
		}
	",
    "data": {
      "header": {
        "name": "Flux",
        "email": "contact@flux.be",
        "phone": "0485 40 26 71",
        "address": "Frankrijklei 67, 2000 Antwerpen",
        "logo": "https://flux.be/wp-content/uploads/2025/06/flux_logo_navy.svg"
      },
      "blocks": [
        {
          "type": "table",
          "data": {
            "title": "Items",
            "description": "These are the items that you have purchased",
            "header": ["Description", "Quantity", "Price", "Total"],
            "items": [["Website Design", 1, 500, 500], ["Hosting", 1, 100, 100]],
            "footer": ["", "", "Total", 600]
          }
        }
      ],
      "footer": {
        "address": "Frankrijklei 67, 2000 Antwerpen",
        "footerText": "Thank you for your business!"
      }
    }
  }'   --output ~/Downloads/invoice.pdf

Error Monitoring & AppID

Each PDF generation request includes an appID parameter that identifies which project or client is generating the PDF. This is useful for:

  • Error Tracking: All errors are captured and tagged with the appID in Sentry
  • Project Filtering: Filter issues in Sentry by appID to see only errors for a specific client
  • Multi-tenant Support: Track errors separately for each project or client

The appID is passed in the API request body and flows through the entire rendering pipeline to Sentry.

Try It Out

Click the button below to generate a sample PDF, or explore the available templates to see how they’re structured and rendered.

Add your own theme

Create custom themes by defining CSS custom properties. Override the default variables to match your brand colors and typography. It is also possible to target classes.

<style>
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@200..800&display=swap');
		
	:root {
		--primary:rgb(59, 25, 25);
		--primary-light:rgb(243, 207, 196);
		--primary-lightest:rgb(255, 241, 242);
		--primary-dark: rgb(10, 13, 24);
		--gray: #474747;
		--gray-light: #E5E5E5;
		--gray-lightest: #f5f5f5;
		--border-radius: 0;
		--font-primary: "Manrope", sans-serif;
	}
</style>

Samples

Available Templates

View and customize the available templates for your documents.