feat(cli): add export-pdf command for vector PDF export#63
Open
Xiaofei-fei wants to merge 1 commit into1weiho:mainfrom
Open
feat(cli): add export-pdf command for vector PDF export#63Xiaofei-fei wants to merge 1 commit into1weiho:mainfrom
Xiaofei-fei wants to merge 1 commit into1weiho:mainfrom
Conversation
Add `open-slide export-pdf` CLI command that exports slides to
high-quality vector PDFs using Playwright.
Usage:
open-slide export-pdf <slide-id>
open-slide export-pdf --all
open-slide export-pdf <slide-id> --out-dir ~/Desktop
How it works:
1. Builds the static site with `open-slide build`
2. Starts a local SPA-aware server
3. For each slide page, navigates to the correct URL
4. Clones the slide canvas into a clean DOM tree (removing
editor chrome like sidebar and toolbar)
5. Uses Chromium's print-to-PDF for true vector output
6. Merges multi-page slides into a single PDF with pdf-lib
Key technique: Chromium's print compositor ignores CSS changes
made via page.evaluate(). Only replacing the DOM tree itself
(with cloneNode + body replacement) reliably removes UI chrome.
|
@Xiaofei-fei is attempting to deploy a commit to the Yiwei Ho Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
open-slide export-pdfCLI command that exports slides to high-quality vector PDFs using Playwright.Usage
How it works
open-slide build?p=N)pdf-libKey technical detail
Chromium's
page.pdf()print compositor has a separate rendering pipeline that ignores CSS changes made viapage.evaluate(),page.addStyleTag(), or evenpage.emulateMedia(). Only replacing the DOM tree itself (usingcloneNode+document.bodyreplacement) reliably removes UI chrome from the PDF output.Output
exports/by defaultDependencies
Adds
playwrightandpdf-libas dependencies to@open-slide/cli.