mirror of
https://github.com/PR0M3TH3AN/Artstr-Studio.git
synced 2026-11-05 05:00:39 +00:00
First slice of Phase E. The Pages overview now has an Export PDF… button that walks the physical-page sequence, renders each page at print DPI, and stamps them into a single PDF via pdf-lib. Library: - Vendored [email protected].1 as src/vendor/pdf-lib.min.js (~513 KB, MIT). Lazy-loaded through loadPdfLibOnce() so the cost is only paid when an author actually exports. Pipeline: - exportBookToPdf({ dpi, includeCover }) walks enumerateBookPhysicalPages(book), rendering each slot at the resolved DPI (default 200) onto a trim-sized canvas: * Designed pages → master underlay + page layers via drawLayerToCanvas, with token substitution applied to master text layers (book.spec.textStyles tokens resolve per page). * Reflow physical pages → master underlay (with text-frame outline stripped) + the pagination engine's block output drawn via fillText at the frame's coordinates. * Cover → wide spread canvas, all book-cover-* / book-spine layers drawn in place. - Each canvas converts to PNG via canvas.toBlob → Uint8Array, then pdf-lib's embedPng + addPage at trimW×trimH points (cover spread is its own landscape page at the end). UI: - Export PDF… button in the Pages overview toolbar with a status line that surfaces progress + warnings (failed image embeds, per-page render errors). - Filename = `<title-slug>.pdf`. Known v1 limitations (handled in later E phases): - Raster-only: every page is a PNG inside the PDF. Real PDF text for embeddable-allowlist fonts comes in E3. - No bleed-inclusive output / crop marks / page-range / two-file modes yet (E2). - Linked-design layers + premium-gated content not exercised. Co-Authored-By: Claude Opus 4.7 <[email protected]>