/** * PDF Export module for Atmosphere Docs. * * Uses html2pdf.js to convert the editor content into a downloadable PDF. * Always exports in light mode regardless of current theme. */ import type { PdfExportOptions } from './types.js'; /** * Build a self-contained HTML string suitable for PDF rendering. * Extracted as a pure function for testability. */ export function buildPdfHtml(editorHtml: string, title: string): string { return `
${editorHtml} `; } /** * Derive a safe filename from a document title. */ export function pdfFilename(title: string | null | undefined): string { const clean = (title || '').trim() || 'Untitled Document'; return clean.replace(/[^a-zA-Z0-9_\- ]/g, '').replace(/\s+/g, '_'); } /** * Generate and download a PDF from editor content. * This is the DOM-coupled entry point — not unit-testable. */ export async function exportPdf({ editorHtml, title }: PdfExportOptions): Promise