fix: Render standard-font PDFs in the proxy image, add a Gemini PDF example - #22
Merged
Conversation
…xample Alpine's poppler-utils ships without the Base-14 PDF fonts (Helvetica, Times, Courier), so the proxy image rasterized those pages blank and the model received an empty image. Adds ttf-liberation, which supplies metric-compatible substitutes. The image grows from about 41 MB to 46 MB. The existing proxy-image PDF test only checked that a valid PNG came back, so a blank page passed. It now requires the rendered page to contain dark pixels, which is what fails when the fonts are missing. Adds examples/go/gemini-pdf: it sends an embedded fake invoice through the Gemini SDK and extracts the fields as structured JSON. Verified end to end against a real llama.cpp with the vision projector; it returns the invoice's actual values. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Fixes a real bug in the
:proxyimage, surfaced while writing a PDF example.:proxycould not render standard-font PDFs. Alpine'spoppler-utilsships without the Base-14 PDF fonts (Helvetica, Times, Courier), sopdftoppmrasterized those pages blank (exit 0, blank PNG), the proxy forwarded an empty image, and the model saw nothing. Every normal invoice, report, or document silently failed. Fix: addfont-liberation(metric-compatible substitutes) to the proxy Dockerfile stage. Image grows ~41 MB to ~46 MB (measured 45.8 MB).examples/go/gemini-pdf: sends an embedded fake invoice through the Gemini SDK with a JSON schema and temperature 0, and extracts the fields. Runs with no setup; pass a path to use your own PDF.Why the schema matters
Without a schema and temperature 0, the small local model returns a plausible-but-invented invoice. The example uses structured output so the model reads the page instead of hallucinating, matching the repo's existing structured-PDF test.
Test Plan
make lintclean, unit tests pass.docker_integrationProxyImage test passes on the fixed image. It fails on a fontless image (verified: render produces exactly zero dark pixels without the font package, ~9000 with it).LK-2026-0042,Acme Robotics,$1,240.00,2026-09-01); without it, the model returned hallucinated values because the page was blank.linux/amd64andlinux/arm64for the pinned Alpine base; font data is architecture-independent.Note
The
:proxyimage published asv0.4.1still has the blank-PDF bug; this warrants av0.4.2once merged.🤖 Generated with Claude Code