8000 feat(documents): make PDFs with anytopdf, here or on a conversion node by adeelahmad · Pull Request #210 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(documents): make PDFs with anytopdf, here or on a conversion node - #210

Merged
adeelahmad merged 2 commits into
mainfrom
claude/project-thread-j5in0x
Oct 6, 2026
Merged

adeelahmad merged 2 commits into
mainfrom
claude/project-thread-j5in0x

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: on a server without LibreOffice and Chromium (the lean image, a Raspberry Pi), Office files, emails, web pages and text couldn't be made into documents. Images were read only by Lens's own OCR.

After: Settings › Documents › Make PDFs with anytopdf (documents.converter):

  • auto (the default) uses anytopdf only where Lens's own converters can't, and only when anytopdf is available. Nothing changes until then.
  • anytopdf (For every document and image) makes Lens download anytopdf v0.3.0 for this machine, checked against the release's checksum, keeping only the program. It also reads images: a photographed page is found and flattened before OCR.
  • lens never uses it.

A conversion node (documents.anytopdf_url plus documents.anytopdf_token) is another machine running anytopdf queue serve. Every conversion goes there as a job, Office files included.

How: anytopdf.py runs the program locally or talks to the node's /v1/jobs API. convert.to_pdf picks it per file, and for text, web pages and emails it hands anytopdf the same cleaned HTML page Lens would print with Chromium. Run locally, anytopdf has no network, no plugins and no config file of its own. Its PDF has no provenance page, entities, colours or places, so documents.read_pdf reads only what the document says. The rendition records by: anytopdf. If anytopdf fails on an image, Lens reads the image itself as before.

Motivation and Context

Phase 1 of the anytopdf integration plan. Before this PR, the v0.3.0 release was tested against Lens's own converters on the same files (report):

  • Office, email, PDF, scans and photos all worked.
  • On a photographed page, flattening found 96% of the words, against Lens's 72%.

Face recognition and object detection stay Lens's own steps. In 0.3.0, face-id matched every face to one person, and the objects plugin only works with AGPL Ultralytics models.

Follow-ups, not in this PR:

  • a threat-model entry for the conversion node (it needs the md, YAML and JSON updated together)
  • a "Check it" button for the node
  • reading anytopdf's structured output once it ships a graph bundle

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (ruff, ruff format, mypy, prettier, tsc pass locally).
  • I added or updated tests. tests/api/test_anytopdf.py uses a fake anytopdf and a fake node. Its last test runs the real v0.3.0 binary when LENS_TEST_ANYTOPDF points at it, and it passed locally.
  • My change requires documentation updates, and I have updated docs/ accordingly (docs/configuration.md#anytopdf).
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HysPx1nJnWBK2JJKbmbqdZ


Generated by Claude Code

Settings › Documents › Make PDFs with anytopdf (documents.converter):
auto uses anytopdf only where LibreOffice and Chromium can't convert,
anytopdf uses it for every document and image (and fetches release
0.3.0, checked against its checksum), lens never. A conversion node
(documents.anytopdf_url + token, `anytopdf queue serve`) converts
Office files too, so a small server needs neither LibreOffice nor
Chromium. Run here it is offline, with no plugins or config file; the
rendition records `anytopdf`. An image anytopdf fails on is read by
Lens as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HysPx1nJnWBK2JJKbmbqdZ
@adeelahmad adeelahmad self-assigned this Oct 6, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HysPx1nJnWBK2JJKbmbqdZ
@adeelahmad
adeelahmad marked this pull request as ready for review October 6, 2026 18:41
@adeelahmad
adeelahmad merged commit 31f7a04 into main Oct 6, 2026
7 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-j5in0x branch October 6, 2026 18:41
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