Add a "Save as PDF" button to every HTML plan so users can download a clean, print-optimized PDF of any plan with a single click -- no external dependencies, no server-side rendering, pure browser-native window.print() with PDF-tuned @media print styles.
add-pdf-export-to-html-plans.html
docs/plans/add-pdf-export-to-html-plans.html
Context
HTML plans are self-contained documents that users open in a browser. The existing @media print rules already hide the sidebar, progress bar, and interactive controls, but there is no visible affordance inviting the user to print or save. Users who want a PDF must know to use Ctrl+P / Cmd+P and select "Save as PDF" in the print dialog.
Adding a dedicated button makes the export discoverable, ensures the print stylesheet is invoked correctly, and sets the document title (which browsers use as the default PDF filename) to a clean slug derived from the plan title.
The approach is zero-dependency: window.print() triggers the browser's native print dialog, which on every modern browser (Chrome, Edge, Firefox, Safari) offers a "Save as PDF" destination. No third-party libraries, no server round-trips, no CORS headaches.
Steps
ic-arrow-down-tray) to the SVG symbol sprite
Verify
id="ic-arrow-down-tray" in the HTML; confirm it renders at 1rem in the button.Verify
.save-pdf-btn and hide it in @media print
Verify
savePDF() function using window.print()
Verify
@media print styles for PDF-quality output
@page margins, break-inside: avoid on cards, preserved background colors for status badges and chips, and suppressed link URL suffixes for internal anchors.Verify
markdown-to-html skill template and assets to include the button and styles
plan-to-html alias delegates immediately to markdown-to-html, which is the active HTML generator with the template, assets, and spec. Updating the alias alone would leave the actual generator unchanged and future plans would still lack the button.Verify
/markdown-to-html on any markdown plan; confirm the generated HTML includes the .save-pdf-btn button and the savePDF() function. Also verify kit/plugins/plan-interview/skills/markdown-to-html/reference/html-spec.md documents the button.Acceptance Criteria
Verification
Open this plan file in Chrome. Click the "Save as PDF" button. In the print dialog, select "Save as PDF" as the destination and click Save. Open the resulting PDF and confirm:
- The sidebar and all buttons are absent.
- The objective card has a blue left border.
- Step cards are not split across pages.
- The status badge retains its gray background.
- The document title in the PDF metadata matches the plan title.
Repeat in Firefox and Safari. Firefox uses its own print engine — confirm the layout is acceptable (minor differences in page breaks are tolerable).
Unresolved Questions
-
Should the button label say "Save as PDF" or "Download PDF"?
The Save as PDF button uses window.print() which opens the browser's print dialog — the user must still select "Save as PDF" as the destination. "Download PDF" implies an instant download. Evaluate which label sets the correct expectation and recommend one. Consider: (1) user familiarity with the print-to-PDF flow, (2) whether "Save" or "Download" is more accurate for a print dialog trigger, (3) what Google Docs and Notion use for similar buttons.