Bad OCR in a board of education annual financial report
This PDF is all sorts of information about the Board of Education in Liberty County, Georgia
pdf.find(text="FINANCIAL HIGHLIGHTS").show()
View full example →
page = pdf.find(text="FINANCIAL HIGHLIGHTS").page
page.show()
View full example →
Complex Extraction of Law Enforcement Complaints
This PDF contains a set of complaint records from a local law enforcement agency. Challenges include its relational data structure, unusual formatting common in the region, and redactions that disrupt automatic parsing.
pdf.add_exclusion(lambda page: page.find(text='L.E.A. Data Technologies').below(include_source=True))
pdf.add_exclusion(lambda page: page.find(text='Complaints By Date').above(include_source=True))
page.show(exclusions='black')
View full example →
complainant = (
section
.find("text:contains(Complainant)")
.right(until='text')
)
print("Complainant is", complainant.extract_text())
View full example →
dob = (
section
.find("text:contains(DOB)")
.right(until='text')
)
print("DOB is", dob.extract_text())
View full example →
Extracting Business Insurance Details from BOP PDF
This PDF is a complex insurance policy document generated for small businesses requiring BOP coverage. It contains an overwhelming amount of information across 111 pages. Challenges include varied forms that may differ slightly between carriers, making extraction inconsistent. It has to deal with different templated layouts, meaning even standard parts can shift when generated by different software.
(
page
.find(text="POLICY NUMBER")
.right(until='text')
.show()
)
View full example →
(
page
.find(text="POLICY NUMBER")
.right(until='text')
.extract_text()
)
View full example →
(
page
.find(text="Mailing Address")
.expand(bottom='text')
.show()
)
View full example →
Extracting Complex Data from Serbian Regulatory PDF
This PDF contains parts of Serbian policy documents, crucial for a research project analyzing industry policies across countries. The challenge lies in extracting a large table that spans pages (page 90 to 97) and a math formula on page 98, all in Serbian. Both elements lack clear boundaries between pages, complicating extraction.
first_page = pdf.find(text="Prilog 7.").page
last_page = pdf.find(text='VISINA NAKNADE ZA ZAGAĐENJE VODA').page
pages = pdf.pages[first_page.index:last_page.index+1]
pages.show(cols=4)
View full example →
region = (
pages
.find(text="Tabela 4")
.below(
until="text:contains(Tabela 5)",
include_endpoint=False,
View full example →
page = pdf.find(text="Obračun naknade za neposredno zagađenje voda").page
page.find("image").show()
View full example →
Extracting Data Tables from Oklahoma Booze Licensees PDF
This PDF contains detailed tables listing alcohol licensees in Oklahoma. It has multi-line cells making it hard to extract data accurately. Challenges include alternative row colors instead of lines ("zebra stripes"), complicating row differentiation and extraction.
header = page.find(text="PREMISE").above()
footer = page.find("text:regex(Page \d+ of)")
(header + footer).show()
View full example →
print("Before exclusions:", page.extract_text()[:200])
# Add exclusions
pdf.add_exclusion(lambda page: page.find(text="PREMISE").above())
pdf.add_exclusion(lambda page: page.find("text:regex(Page \d+ of)").expand())
print("After exclusions:", page.extract_text()[:200])
View full example →
# Add exclusions
pdf.add_exclusion(lambda page: page.find(text="PREMISE").above())
pdf.add_exclusion(lambda page: page.find("text:regex(Page \d+ of)").expand())
print("After exclusions:", page.extract_text()[:200])
View full example →
Extracting Economic Data from Brazil's Central Bank PDF
This PDF is the weekly “Focus” report from Brazil’s central bank with economic projections and statistics. Challenges include commas instead of decimal points, images showing projection changes, and tables without border lines that merge during extraction.
data = (
page
.find(text='Expectativas')
.below(
until='text:contains(comportamento)',
include_endpoint=False
View full example →
row_names = (
data
.find(text='IPCA')
.below(width='element', include_source=True)
.clip(data)
.find_all('text', overlap='partial')
View full example →
.to_df(header=False)
.dropna(axis=0, how='all')
.assign(
year=section.find('text[size~=10]:regex(\d\d\d\d)').extract_text(),
value=headers
)
)
View full example →
Extracting State Agency Call Center Wait Times from FOIA PDF
This PDF contains data on wait times at a state agency call center. The main focus is on the data on the first two pages, which matches other states' submission formats. The later pages provide granular breakdowns over several years. Challenges include it being heavily pixelated, making it hard to read numbers and text, with inconsistent and unreadable charts.
table_area = (
page
.find('text:contains(Figure)')
.below(
until='text:contains(Please use the comments)',
include_endpoint=False
View full example →
ICE Detention Facilities Compliance Report Extraction
This PDF is an ICE report on compliance among detention facilities over the last 20-30 years. Our aim is to extract facility statuses and contract signatories' names and dates. Challenges include strange redactions, blobby text, poor contrast, and ineffective OCR. It has handwritten signatures and dates that are redacted.
with left_col.within() as col:
portion = (
left_col
.find("text:closest(Name and Location)")
.below(
until='text:contains(ICE Information)',
include_endpoint=False
View full example →
label = (
left_col
.find("text:closest(Dates of Review)")
)
print("Found", label.extract_text())
label.show(crop=20)
View full example →
(
left_col
.find("text:closest(County)")
.show(crop=50)
)
View full example →
Natural PDF basics with text and tables
Learn the fundamentals of Natural PDF - opening PDFs, extracting text with layout preservation, selecting elements by criteria, spatial navigation, and managing exclusion zones. Perfect starting point for PDF data extraction.
page.find('rect').show()
View full example →
text = page.find('rect').extract_text()
print(text)
View full example →
# Find red text
red_text = page.find('text[color~=red]')
print(red_text.extract_text())
View full example →
OCR and AI magic
Master OCR techniques with Natural PDF - from basic text recognition to advanced LLM-powered corrections. Learn to extract text from image-based PDFs, handle tables without proper boundaries, and leverage AI for accuracy improvements.
table_area = (
page
.find('text:contains(Violations)')
.below(
until='text:contains(Jungle)',
include_endpoint=False
View full example →
Working with page structure
Extract text from complex multi-column layouts while maintaining proper reading order. Learn techniques for handling academic papers, newsletters, and documents with intricate column structures using Natural PDF's layout detection features.
region = (
flow
.find('text:contains("Table one")')
.below(
until='text:contains("Table two")',
include_endpoint=False
View full example →
page.find('table').apply_ocr()
text = page.extract_text()
print(text)
View full example →
page.find('table').show()
View full example →