Pages

PDFs

An app can print any document as a PDF in its reader's language: a ticket, an invoice, a receipt, a report. This app prints each booking's ticket. Here is one, printed for this page's language, and what it takes, with the lines that do it.

A ticket, printed for this page

The app's own ticket for a sample booking, Laila's seat at an evening of Arabic calligraphy, printed by Browser Run in this page's language. Open it in the other languages from the menu.

The sample ticket

Open the PDF

What a translated PDF needs

Printed by a browser

Arabic must be joined and read right to left, and Thai has no spaces, so its lines must break between words. A browser does all of it, so the PDF is a page of HTML, printed by Cloudflare Browser Run: Chrome on Cloudflare. PDF libraries that draw text themselves get one or the other wrong.

src/pdf.ts
const res = await browser.quickAction("pdf", {

Only the system's fonts

The page names the system's font, as the whole site does, and Cloudflare's Chrome has fonts for Arabic, Thai and the rest, so the app ships no font files at all.

pages/style.css
--font-sans: system-ui, sans-serif;

In the reader's language

A PDF is made away from any page: in a queue, or for a download. void-fbtee's inLocale runs its code in the language saved with the booking, and the page carries that language and direction. An event's title in another language is marked with its own, as on the site.

src/events/tickets.ts
return inLocale(ticket.locale, ({ locale, dir }) =>
src/events/TicketLayout.tsx
<Html lang={locale} dir={dir}>
src/events/TicketLayout.tsx
{titled(heading, title)}

Not while anyone waits

Printing takes up to a second, and the browser can be busy, so booking only sends the booking's id to a queue. Its consumer prints each booking's ticket on its own, so one that fails is tried again a minute later without holding up the others.

pages/[lang]/events/[id].server.ts
await queues.ticket.send({ bookingId: body.id });
queues/ticket.ts
export const maxBatchSize = 1;

Printed once, kept

Each PDF is kept in R2, under the booking's id, so it's printed once however often it's opened. The id is random, so the ticket's address is known only to whoever booked.

src/events/tickets.ts
await storage.put(key, pdf, { httpMetadata: { contentType: "application/pdf" } });

Attached to the email

The ticket goes with the booking's confirmation, in the same language. If it still can't be printed on the last try, the email goes without it, and the ticket is printed when it's downloaded.

src/events/emails.ts
[{ filename: "ticket.pdf", content: booking.ticket, contentType: "application/pdf" }]

Setting it up

Browser Run is a binding in void.config.ts, run on Cloudflare in development too, through Void's Cloudflare sign-in. It needs a compatibility date of 2026-03-24 or later. Cloudflare's free plan gives 10 minutes of browser time a day: about two thousand tickets.

void.config.ts
browser: { binding: "BROWSER", remote: true },
void.config.ts
compatibility_date: "2026-03-24",

The full reference is in void-fbtee's skill.