FixPDF:修正內容,不破壞排版
FixPDF — Make the correction, not the formatting.
開源 PDF 編輯工具 FixPDF 專注修正錯字、日期、姓名和金額等小問題,並盡量保留原有字體與版面。Smart Fix 透過 Ollama 本地運行 Google Gemma 2 (2B),把自然語言指令轉成結構化編輯指令;PDF 編輯引擎負責實際修改。工具亦支援印地語等複雜文字,並以 Layout Guardian 驗證編輯結果。
This is a submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady
What I Built
FixPDF — Make the correction, not the formatting.
FixPDF is a privacy-first PDF editor designed for the small corrections that are surprisingly frustrating to make.
You often don't need to redesign a PDF. You just need to fix one typo, change a date, correct a name, update an amount, or make a small text correction.
The problem is that many PDF editors make these simple changes harder than they should be. After editing, text can change fonts, shift position, lose indentation, overflow its original area, or look noticeably different from the surrounding document. This becomes especially difficult with PDFs containing Hindi/Devanagari and other complex-script text.
FixPDF focuses on solving that annoying part.
Instead of asking the user to manually figure out the font, size, position, spacing, and alignment, FixPDF analyzes the existing PDF and tries to preserve its typography and layout while making only the requested correction.
The workflow is intentionally simple:
Open PDF → Select text → Make the correction → Export.
For natural-language corrections, FixPDF also provides a Smart Fix mode. A locally running open-weight Gemma model interprets instructions such as:
"Change the invoice date to 24 October 2026."
and converts them into a structured editing instruction.
The actual PDF modification is then handled by the PDF editing engine rather than by the AI.
So the user doesn't have to spend five minutes fixing something that should have taken five seconds.
Demo
Video Demo:
The demo shows:
- Opening an existing PDF.
- Selecting a text region.
- Making a small correction.
- Preserving the surrounding formatting.
- Using Smart Fix with a natural-language instruction.
- Editing Hindi/Devanagari text.
- Exporting the corrected PDF.
Code
GitHub Repository:
shahilkhan20
/
pdf-bro
Fast, local-first PDF correction tool that protects formatting, fonts, and layout with Layout Guardian and Indic script shaping
FixPDF (pdf-bro)
"Fix the words. We protect the formatting."
FixPDF is a high-precision, local-first PDF correction suite designed specifically for fixing typos, dates, names, amounts, reference numbers, and localized text in digital documents—without breaking the original font metrics, baseline alignment, quad geometry, or layout boundaries.
Traditional PDF software treats documents like arbitrary desktop publishing canvases: replacement text overflows into neighboring columns, font weights shift, embedded subsets corrupt, or documents get beamed to untrusted cloud APIs. FixPDF takes the opposite approach: deterministic PDF micro-surgery paired with an intelligent Layout Guardian quality gate.
⚡ Key Highlights
- 🔒 100% Local & Air-Gapped: Runs entirely on your local machine. No external cloud dependencies, zero document leakage, private by design.
- 🛡️ Layout Guardian Quality Gate: Real-time simulation of every edit before committing (
EDIT ➔ SIMULATE ➔ MEASURE ➔ VALIDATE ➔ COMMIT). - 📐 Micro-Reflow & Controlled Shrink: Automatic character-spacing tightening…
FixPDF is built as a new open-source project for this challenge.
The repository contains the application code, PDF processing logic, and local AI integration.
How I Built It
FixPDF uses open-source AI locally through Ollama, with Google Gemma 2 (2B) as the primary model for Smart Fix.
The AI has a deliberately limited responsibility.
It does not modify PDF bytes, choose fonts, calculate text coordinates, or directly manipulate document layout.
Instead, Gemma acts as a local natural-language interface.
For example:
User:
"Fix the surname to Sharma."
Gemma:
{
"action": "replace_text",
"replacement": "Sharma",
"layout_preference": "minimal_change"
}
The PDF editing engine then handles the actual document modification, including:
- Identifying the target text.
- Inspecting the PDF's font resources.
- Preserving the original font whenever possible.
- Checking required glyph coverage.
- Handling text shaping for complex scripts.
- Measuring the replacement text.
- Preserving the original position and baseline.
- Detecting overflow and collisions.
- Validating the result before export.
For Hindi and other complex scripts, FixPDF uses shaping-aware rendering rather than treating every character as an independently positioned glyph.
There is also a deterministic fallback parser so that basic editing remains available even when the local AI model is not running.
This makes the normal editing path fast and keeps the AI from becoming a dependency for simple corrections.
The Architecture
User
│
├── Quick Fix ───────────────┐
│ │
└── Smart Fix │
│ │
▼ │
Gemma 2B │
│ │
▼ │
Structured Intent │
│ │
└──────────┬───────────┘
▼
PDF Editing Engine
│
▼
Layout Guardian
│
┌────────┴────────┐
▼ ▼
SAFE UNSAFE
│ │
▼ ▼
Export Don't modify
The key design principle is:
AI understands the user's intention. Deterministic software handles the document.
Why Does Open Innovation Matter?
The biggest reason for using open-weight AI here is local execution.
PDFs often contain sensitive information such as invoices, identity documents, financial records, contracts, government forms, academic documents, and business records.
Sending an entire document to a remote AI API just to understand a simple editing instruction creates an unnecessary privacy and dependency problem.
With a locally running open-weight model, FixPDF can interpret the user's instruction without sending it to an external AI service.
Open models also make the system more controllable. The AI component can be run locally and constrained to structured output instead of giving an external service direct control over the document.
Most importantly, the open model is not being used as a black-box PDF editor.
FixPDF deliberately separates AI reasoning from document manipulation.
This makes the system easier to inspect, test, and run privately on the user's own computer.
That fits the Week 3 Slow and Steady theme: the goal is to make a small, annoying task easier by having the software do the tedious work for you.
My Agent Session
[Add your DevRelay agent session here, if available.]
The Lazy Payoff
PDF editing is one of those tasks where the amount of work is often completely disproportionate to the change being made.
You want to change:
one word.
But you end up:
- Searching for a PDF editor.
- Uploading the document.
- Finding out the useful features are paid.
- Selecting a text tool.
- Trying to match the original font.
- Adjusting the font size.
- Fixing the position.
- Fixing spacing.
- Fixing indentation.
- Checking whether something else moved.
- Exporting.
- Opening the exported PDF again to make sure it didn't break.
FixPDF tries to turn that into:
Select → Correct → Export.
The user shouldn't have to become a typography expert just to correct a typo.
That's the lazy payoff:
Let FixPDF worry about the formatting. You just worry about what the text should say.
來源:DEV Community · dev.to