A professional sales quote template for proposals, with line items and validity period.
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/quote.hbs', 'utf8');
const template = Handlebars.compile(templateSource);
const params = {
company: {
name: 'Northwind Digital',
address: '42 Market Street, San Francisco, CA',
},
quoteNumber: 'Q-2026-017',
validUntil: 'July 10, 2026',
customer: {
company: 'Globex Corporation',
contact: 'Dana Wright',
email: '[email protected]',
},
projectDescription: 'Website redesign package.',
services: [
{ name: 'Discovery workshop', quantity: 1, rate: '$1,200', amount: '$1,200' },
],
subtotal: '$1,200',
tax: '$0',
total: '$1,200',
terms: 'Acceptance requires a 40% deposit.',
};
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('./quote.pdf', response.data);