Repository navigation
feat(documents): use the word boxes anytopdf read instead of reading its PDF again - #223
Merged
Merged
Conversation
…its PDF again Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P31n7kxdbS48U1qGzfzt18
…-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
21 of 23 tasks
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.
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.jsonanytopdf 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 readsimage+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_blocksgroup words into lines and reusemerge_linesfor paragraphs;read_pdftakes 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