feat(edit-pdf): add editing for existing PDF text - #111
Open
stidven-wq wants to merge 1 commit into
Open
Conversation
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
Adds in-place editing of existing PDF text to the current PDF.js annotation
interface.
Users can activate Edit text, select an existing text span, preview a
replacement, choose how overflow should be handled, and apply the change
without uploading the document to a server.
Motivation
The existing editor supports annotations and new content, but it does not
modify text already present in the PDF. This change makes common corrections
possible without requiring the original source document or a separate desktop
PDF editor.
What changed
Implementation
Text replacement is performed locally through the existing PyMuPDF WASM
runtime:
vector graphics.
diagnostics.
No document content is sent to an external service.
Validation
tsc --noEmitvitest run src/__tests__/lib/pdf/replace-existing-text.test.ts src/__tests__/components/tools/EditPDFTool.test.tsxThe full repository suite currently reports 451/452 passing tests. The remaining
failure is the pre-existing
ToolSidebarpointer-drop test and is reproduciblewithout these changes.
The repository's
lintscript currently cannot run because ESLint 9 does notfind an
eslint.config.jsconfiguration file.Limitations
its subset contains the new glyphs.
current interaction edits the selected span.
extend beyond the original area; users can choose shrink or expand instead.
Files of interest
src/components/tools/edit-pdf/EditPDFTool.tsxsrc/lib/pdf/processors/replace-existing-text.tssrc/lib/pdf/pymupdf-loader.tssrc/__tests__/lib/pdf/replace-existing-text.test.ts