import { PondFonts, fontStack } from '@dorfteich/shared'; export interface PdfHtmlParams { title: string; pondName: string; /** The page's cached body HTML with images already inlined as data URIs. */ bodyHtml: string; fonts: PondFonts; /** Pre-built `@font-face` rules (base64 WOFF2) for the pond's fonts. */ fontFaceCss: string; /** The pond's active section-style plugin CSS (issue #75), already validated * at install time (scoped selectors, no external fetches, no ``). * Sections of a disabled plugin render neutrally — their class matches * nothing. */ sectionStyleCss?: string; } function escapeHtml(value: string): string { return value .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"'); } /** * Build the standalone HTML sent to Gotenberg for PDF export (ADR 0009/0016). * No app chrome; the pond's fonts are applied via CSS variables (their * `@font-face` rules are inlined as base64 so the render makes no network * request), a title header sits above the content, and print CSS sets the page * size and sensible break behaviour. Page numbers come from Gotenberg's footer. * * Plugin blocks arrive already degraded to their static form — the caller runs * `PluginFallbackRenderer.applyToHtml` (#79) before building this document. */ export function buildPdfHtml(params: PdfHtmlParams): string { const { fonts } = params; return ` ${escapeHtml(params.title)}

${escapeHtml(params.pondName)}

${escapeHtml(params.title)}

${params.bodyHtml}
`; }