feat(pdf): File Convert category + PDF → image tool#100
Merged
Conversation
New top-level "File Convert" category (sidebar + home grid) whose first tool, "PDF Convert", rasterizes PDF pages to PNG / JPEG / WebP entirely in the browser — no upload, no external calls. - pdfjs-dist for rendering; worker bundled same-origin via ?url. - cmaps / standard_fonts / wasm served from public/pdfjs/ (not a CDN) so CJK + no-embedded-font PDFs render and cross-origin isolation / the no-external-calls rule both hold. - Per-page format, DPI preset (72–600), page-range parser (1-3,5,8-), JPEG/WebP quality slider. JPEG/WebP get a white matte (no black alpha). - Sequential render + eager canvas release (multi-page won't OOM); canvas dims clamped to browser limits. Scripting/XFA left off, so embedded PDF JavaScript never runs. - Per-page + ZIP (fflate, stored) download. i18n in en + zh-CN. - Unit tests for the page-range parser (7 cases). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XBhzzooAQNwaM4vg1CmpFo
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.
What
Adds a new top-level File Convert category (first-level menu) and its
first tool, PDF Convert (second-level), starting with PDF → image.
All rendering is client-side — nothing is uploaded and no external calls are
made.
How it works
pdfjs-dist) renders each page to a canvas. The worker isbundled same-origin via
?url(version-matched, COEP-safe).cmaps/,standard_fonts/,wasm/— are copied intopublic/pdfjs/and served from our own origin, not a CDN. That'srequired twice over: the site is COOP/COEP cross-origin-isolated (CDN URLs
would be COEP-blocked) and the project rule is no external data flow. This
is also what makes CJK / no-embedded-font PDFs render real glyphs.
page range (
1-3, 5, 8-), and a quality slider for lossy formats.otherwise come out black). Pages render sequentially with the canvas
released between pages (a 50-page export won't OOM); canvas dims are clamped
to browser limits. Scripting/XFA stay off → embedded PDF JavaScript never runs.
fflate, stored — images arealready compressed).
enandzh-CN. Command palette + home grid pick itup automatically from the tool registry.
Verification
pnpm typecheck/lint/buildgreen;pnpm test393 passing (7 newfor the page-range parser).
pnpm preview(real COOP/COEP headers) on a 3-pageCJK PDF:
crossOriginIsolated: true, all pages rendered at correct150-DPI dims with color + Chinese glyphs, JPEG corner
[255,255,255](white matte confirmed), zero external requests from pdf.js, no console
errors.
Notes
public/pdfjs/is ~4 MB of versioned pdf.js runtime assets, committed soprod is self-contained.
src/lib/pdf.tsdocuments the re-copy step onpdfjs-dist upgrades.
in later under the same category.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XBhzzooAQNwaM4vg1CmpFo