A clean, minimal black & white invoice template ready for billing clients.
Download the prepared Handlebars template, render it with runtime params, and send the final HTML to the html2pdf.app API.
import fs from 'fs';
import axios from 'axios';
import Handlebars from 'handlebars';
const templateSource = fs.readFileSync('./templates/invoice.hbs', 'utf8');
const template = Handlebars.compile(templateSource);
const params = {
company: {
name: 'Acme Studio',
address: '123 Main Street, San Francisco, CA 94103',
},
customer: {
name: 'Globex Corporation',
address: '500 Market Street\nSan Francisco, CA 94105',
email: '[email protected]',
},
invoice: {
number: 'INV-00042',
issueDate: '2026-06-09',
dueDate: '2026-07-09',
},
project: {
name: 'Brand and web delivery',
description: 'Design, development, and consulting services for the current billing period.',
},
items: [
{
description: 'Brand identity design',
quantity: 1,
unitPrice: '$2,400.00',
amount: '$2,400.00',
},
],
totals: {
subtotal: '$2,400.00',
tax: '$204.00',
total: '$2,604.00',
},
paymentTerms: 'Payment is due within 30 days.',
bankDetails: 'Acme Studio - Routing 021000021 - Account 000123456789',
notes: 'Thank you for your business.',
};
const html = template(params);
const response = await axios.post(
'https://api.html2pdf.app/v1/generate',
{ html },
{
responseType: 'arraybuffer',
headers: {
'X-API-Key': process.env.HTML2PDF_API_KEY,
},
},
);
fs.writeFileSync('./invoice.pdf', response.data);