Improving AI Articles With Native PDF Processing
Text extraction mangled budget tables and lost column relationships. Sending raw PDF bytes to Claude produced more accurate dollar figures and specific dates.
The Miami Beach Journal generates articles from city government PDFs -- budget amendments, zoning proposals, commission memoranda. I was extracting text with pdftotext first, then feeding it to Claude. For budget tables, this produced garbled output:
GO #34 ABOVE GROUND IMPROV - TOWN CTR - TRANCHE 2
(Project # 27519-NEW)
GO #36 WASHINGTON AVE. CORRIDOR - TRANCHE 2 (Project #
397,616.00 9,602,384.00 10,000,000.00
27719-NEW)
Project names, dollar amounts, and project numbers scattered across lines with no clear relationship. The column alignment that makes the original table readable is completely lost.
The Fix
Anthropic's API supports native PDF document input. Instead of extracting text, send the raw bytes:
{
"type": "document",
"source": {
"type": "base64",
"media_type": "application/pdf",
"data": "<raw PDF bytes>"
}
}
Claude sees the original table layouts, column relationships, charts, and even scanned images.
Side-by-Side Comparison
Tested on the same document -- Third Amendment to the FY 2026 Capital Budget:
Text extraction: Listed budget items in narrative paragraphs. Said "today" instead of the specific date. Rounded Above Ground Improvements to $9 million. 29 dollar figures cited. 9,386 input tokens.
Native PDF: Bold project names with individual breakdowns. Cited the exact February 5 commission resolution date. Noted the correct $10.1 million for Above Ground Improvements. Included a direct quote from the City Manager's memorandum. Specified "2:00 p.m. on February 25, 2026." 26 dollar figures cited. 28,248 input tokens.
About 3x more tokens, but for civic journalism where accuracy matters, the quality justifies the cost. I kept text extraction as a fallback for PDFs exceeding Claude's 32MB limit, but native processing is now the default.
Built while working on Miami Beach Civic Journal.
Back to danielships ->