A compact admission ticket with event details, seat info, and a barcode placeholder.
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/event-ticket.hbs', 'utf8');
const template = Handlebars.compile(templateSource);
const params = {
eventName: 'Design Systems Summit',
eventDescription: 'One-day conference for product teams.',
date: 'Oct 18, 2026',
time: '09:30',
venue: 'Hall B',
seat: 'A-24',
ticketNumber: 'DS-88421',
};
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('./event-ticket.pdf', response.data);