8000 feat(documents): use the word boxes anytopdf read instead of reading its PDF again by adeelahmad · Pull Request #223 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(documents): use the word boxes anytopdf read instead of reading its PDF again - #223

Merged
adeelahmad merged 3 commits into
mainfrom
claude/project-thread-xbs7t4
Oct 7, 2026
Merged

adeelahmad merged 3 commits into
mainfrom
claude/project-thread-xbs7t4

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Before: when anytopdf made a document's or image's PDF, Lens read that PDF again with pdftotext, and a scanned or photographed page needed Lens's own OCR engine to have any text.

After: Lens reads the anytopdf-chunks.json anytopdf 0.4.0 embeds in its PDF. On every picture page where anytopdf listed its words with their boxes, those words become the page's blocks (lines, then paragraphs, each with its place on the page) and the page is not read again. The page is marked as read by OCR when anytopdf's OCR found the words, and the engine reads image+ocr:anytopdf. Pages without words (an email's own text, PDFs from older anytopdf) are read as before.

How: anytopdf.page_words(pdf) reads the embedded chunks with pypdf, so it works the same for a local binary and a conversion node. documents.word_lines / word_blocks group words into lines and reuse merge_lines for paragraphs; read_pdf takes the known pages and skips pdftotext and OCR for them. Tested against the real anytopdf 0.4.0 (text PDF, docx, scanned PDF, photographed page with Tesseract) as well as the fake.

🤖 Generated with Claude Code

https://claude.ai/code/session_01P31n7kxdbS48U1qGzfzt18


Generated by Claude Code

…its PDF again

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P31n7kxdbS48U1qGzfzt18
@adeelahmad adeelahmad self-assigned this Oct 7, 2026
claude added 2 commits October 7, 2026 12:18
…-xbs7t4

# Conflicts:
#	CHANGELOG.md
#	fastapi_backend/app/domain/anytopdf.py
#	fastapi_backend/tests/api/test_anytopdf.py
…nswers

The node answered before reading Lens's upload, so Lens could see a connection reset instead of the answer.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P31n7kxdbS48U1qGzfzt18
@adeelahmad
adeelahmad merged commit 68d7509 into main Oct 7, 2026
7 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-xbs7t4 branch October 7, 2026 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0