Event Ticket

A compact admission ticket with event details, seat info, and a barcode placeholder.

  • Admission
  • Compact
  • Barcode
Accent color
Panel color

Black and white with grey panels by default. Both colors are template params, accentColor and panelColor, so one file works for every combination.

How to use

Render the template, then convert it to PDF

Download the prepared Handlebars template, render it with runtime params, and send the final HTML to the html2pdf.app API.

import { readFile, writeFile } from 'node:fs/promises';
import Handlebars from 'handlebars';

// Download the template from https://html2pdf.app/template-files/event-ticket.hbs
// and keep a copy next to your code, so our updates never change your PDFs.
const templateSource = await readFile('./templates/event-ticket.hbs', 'utf8');
const template = Handlebars.compile(templateSource);

const params = {
  // Optional colors. Leave them out for black and white with grey panels.
  // accentColor: '#1d4ed8',
  // panelColor: '#edf1fc',
  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 fetch('https://api.html2pdf.app/v1/generate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': process.env.HTML2PDF_API_KEY,
  },
  body: JSON.stringify({ html }),
});

if (!response.ok) {
  throw new Error('PDF generation failed with status ' + response.status);
}

const pdf = Buffer.from(await response.arrayBuffer());
await writeFile('./event-ticket.pdf', pdf);