Skip to content

fix(mobile): allow selecting PDF text layer#437

Open
codedogQBY wants to merge 1 commit into
mainfrom
codex/fix-mobile-pdf-text-selection
Open

fix(mobile): allow selecting PDF text layer#437
codedogQBY wants to merge 1 commit into
mainfrom
codex/fix-mobile-pdf-text-selection

Conversation

@codedogQBY

Copy link
Copy Markdown
Owner

Analysis

  • Mobile PDF pages render as fixed-layout iframes with a canvas, a PDF.js text layer, and an annotation layer.
  • The canvas/annotation layer could win touch hit-testing over the transparent text layer, while the PDF text layer also defaulted to panning-oriented cursor/gesture behavior.
  • For PDFs that contain an actual text layer, Android long-press selection should hit the text spans so the existing ReadAny selection popover can copy the text. Image-only scanned PDFs still do not expose selectable text without OCR.

Changes

  • Detect PDF text-layer documents in the mobile reader template.
  • Disable pointer events/user selection on the PDF canvas so it does not consume text gestures.
  • Promote .textLayer and its spans as selectable touch targets, while keeping PDF link annotations clickable.
  • Rebuilt packages/app-expo/assets/reader/reader.html from the template.

Verification

  • pnpm --filter @readany/app-expo run build:reader
  • git diff --check
  • rg -n "isPdfTextLayerDoc|getPdfTextSelectionStyles|annotationLayer section|#canvas, #canvas canvas|touch-action: auto" packages/app-expo/assets/reader/reader.template.html packages/app-expo/assets/reader/reader.html

Note: pnpm exec biome check packages/app-expo/scripts/build-reader.js still reports pre-existing style issues in the build script (node: protocol and template-string suggestions); this PR does not touch that script.

Fixes #362

@codedogQBY codedogQBY added bug Something isn't working priority:p1 High: important feature broken or major platform/workflow regression area:reader Reader, pagination, scrolling, layout, TOC area:pdf PDF reading, import, selection, vectorization area:mobile Mobile, tablet, React Native, Android, iOS labels Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:mobile Mobile, tablet, React Native, Android, iOS area:pdf PDF reading, import, selection, vectorization area:reader Reader, pagination, scrolling, layout, TOC bug Something isn't working priority:p1 High: important feature broken or major platform/workflow regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] PDF文件的文字无法选取内容并复制

1 participant