Repository navigation
Add local PDF compression and improve PDF editing UX - #2
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new compression feature likely cannot load its worker/WASM assets with the current URL strategy, which would cause compression to fail at runtime.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR expands the PDF Toolkit’s core workflows by adding browser-local PDF compression (qpdf/WASM) and improving multi-PDF UX so users can explicitly choose which PDF is being edited/compressed while keeping merge behavior order-based.
Changes:
- Added qpdf-run based compression modes (lossless/balanced/strong) with size reporting and “don’t download larger output” behavior.
- Improved multi-PDF UX: remove per file, clear all, re-add same file, and explicit “working PDF” selector for edit/compress/metadata.
- Updated dependencies and version bump to include
qpdf-run.
File summaries
| File | Description |
|---|---|
| src/app/pdf-toolkit/page.tsx | Adds local qpdf/WASM compression and reworks the PDF selection/editing UX for multi-file workflows. |
| package.json | Bumps app version and adds qpdf-run dependency. |
| package-lock.json | Regenerates lockfile to include qpdf-run and version bump. |
Review details
- Files reviewed: 4/5 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟡 Changes recommended
There are verified issues that can cause dev-time unhandled promise rejections, state update clobbering in React, and missing gitignore coverage for generated public/pdfjs/ assets.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (1)
src/app/pdf-toolkit/page.tsx:237
removeFileusessetFiles(next)computed from the render-timefilesarray. If anothersetFilesupdate is queued (e.g., a quick reorder click followed immediately by remove before React commits), this non-functional update can clobber the other update and restore stale state.
const removeFile = async (key: string) => {
const next = files.filter(item => fileKey(item.file) !== key);
setFiles(next);
setMessage('');
- Files reviewed: 9/11 changed files
- Comments generated: 1
- Review effort level: Lite
Summary
This follow-up improves the PDF Toolkit around the most common PDF workflows while keeping all processing local in the browser.
PDF compression
Browser compatibility
public/qpdf/before dev/build to avoid Next 16/Turbopackfile:///worker companion URLspublic/pdfjs/Merge workflow
Editing workflow
PDF to edit or compressselector when multiple PDFs are loadedPage operationssection toEdit pages in a PDFDependencies and verification
qpdf-runfor structural compressionpdfjs-distfor reliable browser-side flattened compressionpackage-lock.jsonis generated through npm rather than hand-editednpm audit --omit=devreports 0 vulnerabilitiesnpm audit --omit=dev --audit-level=highAll PDF files remain on the user's device; no upload/API service is introduced.