๐ Try the demo: https://github.com/LM-Kit/lm-kit-net-samples/tree/main/console_net/document-intelligence/document-parsing/chart_data_harvester
Chart Data Extraction for C# .NET Applications (PDFs, Scans and Images)
๐ฏ Purpose of the Demo
Chart Data Harvester reads the numbers behind every chart of a folder of documents with
LM-Kit.NET's AI document parser, DocumentParser. Each chart comes back as a
ChartContent:
its data table, the title it prints, its legend, and one table per panel for a figure of several
plots. The demo writes each table as CSV beside the chart's picture and indexes them all.
The sample shows how to:
- Parse at
ParsingEffort.High, the level for data that must be right. - Find the
ChartContentelements of every page and readText,Caption,LegendandPanels. - Keep each chart's picture with
IncludeFigureImagesandParsedElement.GetImage(). - Write a review page per document with
SaveHtml.
๐ฅ Target Audience
- Financial and research analysts turning reports and filings into data.
- Data engineers who need chart values in a warehouse, not a picture in a PDF.
- RAG builders who want questions about numbers to find the chart that holds them.
๐ Problem Solved
- Charts are data, not pictures. Text extraction sees nothing inside a chart; the parser reads what it plots.
- Context kept. The title and legend travel with the table, so each CSV says what it measures.
- Reviewable. The picture sits beside the numbers for a quick human check.
๐ป Demo Application Overview
Enter a folder. The demo parses every supported document in it and writes, under
<folder>/charts/, one CSV per chart (and per panel), one PNG per chart, one HTML review page
per document, and index.csv listing every chart with its document, page and title.
โจ Key Features
- Every chart of every page, in reading order.
- Multi-panel figures split into one table per panel (
HasPanels,Panels). - CSV conversion from the Markdown data table, with quoting where needed.
- A one-file index of the whole harvest.
Example Output
paper.pdf
page 6: Figure 5. A tree with two traces, a trunk trace and one branch trace. The t... (1 table)
page 11: Figure 10. Speedup vs. a baseline JavaScript interpreter (SpiderMonkey) for... (1 table)
8 chart(s) harvested into reports\charts
paper-p11-c1.csv:
Characteristic,Tracing,SFX,V8
3d-cube,2.2,2.0,3.0
3d-morph,3.0,2.0,2.3
3d-raytrace,1.3,2.8,2.6
๐๏ธ Architecture
folder of documents
โ
โผ
DocumentParser(High) { IncludeFigureImages = true }
โ
โผ
ParsedPage.Elements โโ ChartContent โโ Text / Panels โโโบ CSV
โ
โโโ GetImage() โโโโโโโโโโโบ PNG
โ
โโโ SaveHtml() โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโบ review page
โ๏ธ Getting Started
๐ Prerequisites
- .NET 8.0 or later
- A GPU is recommended;
Higheffort is the slowest level - About 2.5 GB of disk for the models, downloaded on first run
๐ฅ Download the Project
git clone https://github.com/LM-Kit/lm-kit-net-samples
cd lm-kit-net-samples/console_net/document-intelligence/document-parsing/chart_data_harvester
โถ๏ธ Run the Application
dotnet run
๐ง Troubleshooting
| Problem | Fix |
|---|---|
| A chart is missing from the index | It was read as a picture (FigureContent); try a higher effort level |
| The run is slow | Change the Effort constant to Medium |
| Numbers look shifted | Open the review page and compare the table with the picture beside it |
๐ Extend the Demo
- Load the CSVs into a database or a dataframe.
- Index the charts for questions: see the Parsed Document RAG demo.