Implement PDF Knife: Client-side PDF manipulation web app#1
Implement PDF Knife: Client-side PDF manipulation web app#1Ghostwillower merged 6 commits intomainfrom
Conversation
Co-authored-by: Ghostwillower <153353690+Ghostwillower@users.noreply.github.com>
Co-authored-by: Ghostwillower <153353690+Ghostwillower@users.noreply.github.com>
Co-authored-by: Ghostwillower <153353690+Ghostwillower@users.noreply.github.com>
Co-authored-by: Ghostwillower <153353690+Ghostwillower@users.noreply.github.com>
Co-authored-by: Ghostwillower <153353690+Ghostwillower@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR implements PDF Knife, a client-side web application for manipulating PDFs (merging, reordering, rotating, and deleting pages) entirely in the browser without server dependencies.
Key Changes:
- Created a vanilla JavaScript web app using pdf.js for rendering thumbnails and pdf-lib for PDF assembly
- Implemented HTML5 drag-and-drop for page reordering with visual feedback
- Added page rotation (90° increments) with CSS transforms for preview and pdf-lib for actual PDF modification
Reviewed changes
Copilot reviewed 6 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| index.html | Defines the app structure with navbar controls and page grid container |
| style.css | Provides responsive grid layout with drag-and-drop styling and rotation classes |
| script.js | Implements core functionality: PDF loading, thumbnail rendering, drag-and-drop, rotation, and export |
| package.json | Declares dependencies for pdf.js and pdf-lib libraries |
| README.md | Documents features, installation, usage, and technical architecture |
| USAGE.md | Provides quick start guide and troubleshooting tips |
| .gitignore | Excludes node_modules and package-lock.json |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| thumbnail: thumbnail, | ||
| pdfjsPage: page |
There was a problem hiding this comment.
The pdfjsPage property is stored in each page object but is never used in the codebase. This stores potentially large objects in memory unnecessarily. Consider removing this property unless it's needed for future functionality.
| thumbnail: thumbnail, | |
| pdfjsPage: page | |
| thumbnail: thumbnail |
| /* Pages Grid */ | ||
| .pages-grid { | ||
| display: grid; | ||
| grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); |
There was a problem hiding this comment.
[nitpick] The magic number 200px for minimum card width lacks context. Consider defining this as a CSS custom property (e.g., --card-min-width: 200px) at the root level for easier maintenance and consistency with the responsive breakpoint at line 267 which uses 150px.
Built a vanilla JS web application for merging, reordering, rotating, and editing PDFs entirely in the browser with no server dependencies.
Implementation
Core Architecture
index.html- Structure with upload controls and page grid containerstyle.css- Responsive grid layout with drag-and-drop visual feedbackscript.js- Page management using unified array:{id, sourceIndex, pageNumber, rotation, pdfDoc}Libraries (local)
Key Features
setRotation()for actual PDF modificationcopyPages()workflow: load → reorder → rotate → assemble → downloadTechnical Details
ES module integration:
Page state management maintains source references for later assembly:
Screenshots
Empty state:

Working with pages:

Rotation applied:

Page deletion:

Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
cdnjs.cloudflare.com/usr/bin/curl curl -L -o pdf.min.js REDACTED(dns block)unpkg.com/usr/bin/curl curl -L -o pdf.min.js REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.