Table of Contents

๐Ÿ‘‰ 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 ChartContent elements of every page and read Text, Caption, Legend and Panels.
  • Keep each chart's picture with IncludeFigureImages and ParsedElement.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; High effort 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


๐Ÿ“š Additional Resources

Share