An enterprise-grade, high-performance NestJS service to generate branded, multi-page PDFs using Puppeteer.
Professional Branded PDF with QR Code and Watermark
Included Postman Collection for easy testing
- Singleton Browser Pooling: Efficiently reuses Chromium instances using incognito contexts to minimize memory overhead.
- Concurrency Control: Integrated request queuing via
p-queueto handle traffic spikes without crashing. - Advanced HTML Templates: Ready-to-use branded receipt layout with:
- Dynamic QR Codes: Auto-generated from verification URLs.
- Watermarks: Semi-transparent "PAID" watermark on every page.
- Multi-page Support: Automatic headers and footers with page numbering.
- Strict Validation: Type-safe endpoints using
class-validatorandclass-transformer. - Production Ready: Optimized for Linux/EC2 environments with necessary Puppeteer flags.
- Node.js (v18+)
- Chromium (for Linux servers)
# Install dependencies
npm install# development
npm run start:dev
# production mode
npm run build
npm run start:prodUse for simple download links.
GET /pdf/receipt?name=John+Doe&orderId=INV-001&amount=599.99&logoUrl=...&verifyUrl=...
Use for complex data or item lists.
POST /pdf/receipt
Payload Example:
{
"name": "Jane Smith",
"orderId": "INV-2026-X",
"amount": 1250.00,
"logoUrl": "https://example.com/logo.png",
"verifyUrl": "https://verify.me/inv-x",
"items": [
{ "description": "Consulting Fee", "quantity": 1, "rate": 1000 },
{ "description": "Taxes", "quantity": 1, "rate": 250 }
]
}- Postman: Import
postman_collection.jsonlocated in the root directory. - Automated Verification: Run
npx ts-node verify-unified.tsto simulate a production render. - Guide: Refer to TESTING_GUIDE.md for detailed steps.
For Ubuntu/EC2 setup, see PRODUCTION_GUIDE.md.
MIT