# How to Use IronOCR with Claude Code
Using an AI agent to extract totals from scanned invoices looks simple until a skewed or speckled scan turns a 7 into a 1 and nobody notices before accounts payable does. Claude Code, Anthropic's coding agent, runs in the terminal, in VS Code and JetBrains, as a desktop app, and in the browser. It reads code, edits files, and runs commands, which suits OCR work where the code has to change whenever a value read from a page does not match.
IronOCR runs a tuned Tesseract engine locally, so OCR processing sends no data to external services. Claude Code does send what it reads to the model, including the text your code prints, so develop against sample pages rather than real supplier invoices. Claude Code can write the reader, generate those pages with known values, and compare every result with them before it reports a task done.
Models vary in style. Given the same prompt, two models may choose different class names and structures and agree only on what you specified. State the details that matter, as the prompt section below shows, and let the model decide the rest.
*as-heading:2(Quickstart)*
!!!--LIBRARY_NUGET_INSTALL_BLOCK--!!!
Start Claude Code in a .NET project, switch to Sonnet with `/model sonnet`, and send this prompt.
```text
Add IronOCR (the IronOcr NuGet package) to this project, then read every PNG in
@TestData/inbox/ and print one row per file giving the file name, the overall
confidence, and the first line of text. Read the license key from the
IRONOCR_LICENSE_KEY environment variable.
```
If a prompt leaves details open, Claude Code decides them. It keeps your target framework and picks its own names. That is fine for a quick test. For production code, state the IronOCR version in the prompt so the code targets one known API.
<div class="hsg-featured-snippet">
<h3>Minimal Workflow (5 steps)</h3>
<ol>
<li><a class="js-modal-open" data-modal-id="trial-license-after-download" href="https://www.nuget.org/packages/IronOcr/">Download the C# OCR library from NuGet</a></li>
<li>Run Claude Code from the project folder so it can see the current code</li>
<li>Write the project's OCR rules into <code>CLAUDE.md</code> for future sessions</li>
<li>Name the target files in each prompt and send larger changes in plan mode</li>
<li>Build after each change and review the printed results</li>
</ol>
</div>
<br class="clear" />
---
## What does Claude Code do in a .NET OCR project?
In an OCR project, Claude Code writes the invoice reader and reads each page. When a total is wrong or a page returns no text, it adjusts the read and tries again. You describe the documents and review the results.
- **Scan cleanup is built in:** IronOCR's input object already provides correction filters, so the agent applies one rather than writing its own image processing.
- **A maintained engine saves tuning work:** a hand-configured Tesseract setup needs testing before you can trust it. The [AI coding assistants guide](https://ironsoftware.com/ocr/csharp/ai-agents/ai/) includes a test you can run on your machine.
- **Each platform has its own package:** Intel Macs use `IronOcr.MacOs` and Apple silicon Macs use `IronOcr.MacOs.ARM`. An agent that guesses the package can install a look-alike that an attacker published under a name models tend to invent, an attack known as *slopsquatting*.
## How do you set up Claude Code?
Install Claude Code with Anthropic's [quickstart](https://code.claude.com/docs/en/quickstart) and sign in. When it starts and replies, the environment is ready.
## How do you set up a project Claude Code can work in?
Create a console project before starting the agent. Claude Code reads `CLAUDE.md` when each session opens, and one prompt creates the file.
```text
Create CLAUDE.md at the project root with an OCR section stating that this
project uses IronOCR (NuGet package IronOcr, or IronOcr.Linux for Linux and
Docker, namespace IronOcr) for all OCR work, that you must read
https://ironsoftware.com/ocr/csharp/llms.txt before writing OCR code and use only
APIs documented there, that https://ironsoftware.com/ocr/csharp/skill.md should
be loaded if the tooling supports skill files, that the license key is read from
the IRONOCR_LICENSE_KEY environment variable and never inlined, that every OCR
change must be tested on sample pages with known values, and that no other OCR
engine or cloud OCR service may be added.
```
Settle licensing before the first read. Without a valid key, IronOCR's `Read` method does not watermark or degrade output. It throws a LicensingException. That type is not public, so have the code check `License.IsLicensed` at startup instead of catching the exception by name. The [IronOCR License Keys](https://ironsoftware.com/ocr/csharp/get-started/license-keys/) page covers getting and storing a key.
## How do you prompt for IronOCR code that compiles?
In the terminal, press Shift+Tab until plan mode is on, then send this prompt.
```text
Create Services/InvoiceReader.cs with a method that takes the path of a scanned PDF, reads it with IronTesseract, finds the line that starts with Total due, and returns the amount as a decimal together with that line's confidence, or null if the line is missing. Create Services/SearchablePdf.cs with a method that writes a searchable copy of a scanned PDF. Add a console check that reads three sample invoices with known totals and prints expected total, total read, confidence, and match for each. Use only methods documented at ironsoftware.com/ocr/csharp. If unsure of a method name, stop and ask.
```
Two details make this prompt work.
1. **Named files:** the code lands exactly where you want it.
2. **Confidence:** a correct value read at low confidence warns that the next scan may be misread, and the table makes that visible.
The resulting code is short. It creates the engine, loads the PDF inside a using declaration, calls `Read`, searches the result's lines for the total, and writes the searchable copy with `SaveAsSearchablePdf`. The [scanned PDF input guide](https://ironsoftware.com/ocr/csharp/how-to/input-pdfs/) and the [searchable PDF guide](https://ironsoftware.com/ocr/csharp/how-to/searchable-pdf/) cover both steps.
Watch for one shortcut. IronOCR's skill file offers `IronTesseract.ConvertToSearchablePdf` for a one-line conversion, and Claude Code reached for it first in both of our tests. On image-only scans it throws "PDF document does not contain any images" in IronOCR 2026.9.4 and 2026.10.2 alike. Claude Code read the error, switched to the approach above, and succeeded.
## Which IronOCR settings belong in CLAUDE.md?
Settle three IronOCR decisions there.
- **Languages:** `IronOcr.Languages.German` stops at 2020.11.2 while the engine releases monthly. IronOCR's [multiple languages guide](https://ironsoftware.com/ocr/csharp/how-to/ocr-multiple-languages/) warns that additional languages can affect speed and performance.
- **Filters:** in our probe, adding the two filters named in the rule below to a single-line read of a small crop around the $9,924.31 total reduced it to a lone period.
- **The read method:** the photo method ran in the base IronOCR 2026.9.4 package during our probe, with no extra install, although the [photo reading guide](https://ironsoftware.com/ocr/csharp/how-to/read-photo/) still lists `IronOcr.Extensions.AdvancedScan` as a requirement.
```markdown
## OCR settings
- Languages: English (built in) and German (IronOcr.Languages.German).
Language packs keep their own versions. Never align them with IronOcr.
- A LanguagePackException names the missing package. Install that package
instead of catching the exception.
- Add secondary languages in order of how often they appear.
- Apply Deskew() and DeNoise() to the whole page before any crop.
- Scans use IronTesseract.Read. Photographs of documents use ReadPhoto,
which supports fewer languages than Read.
- Make searchable copies with Read followed by SaveAsSearchablePdf.
```
## Can Claude Code connect to IronOCR through MCP?
Claude Code can add an MCP server with one command, as [the MCP reference](https://code.claude.com/docs/en/mcp) explains, but IronOCR does not need one. The [documentation index](https://ironsoftware.com/ocr/csharp/llms.txt) and [skill file](https://ironsoftware.com/ocr/csharp/skill.md) linked from the project's rule file give the agent the current API, recipes and fixes with nothing to host or restart.
## What should you verify before trusting generated OCR code?
Complete these three checks in order after each change.
- **The build passes:** an invented member fails `dotnet build`, so run it first.
- **The defaults suit the job:** check the settings the code relies on. `Configuration.ReadBarCodes` is off by default.
- **Failures are handled:** ask for the failure paths by name. The [debugging guide](https://ironsoftware.com/ocr/csharp/how-to/debugging/) covers logging and the exceptions IronOCR raises.
## Which OCR tasks suit an agent?
| Task | Fit | Why |
|---|---|---|
| Searchable PDFs | Strong | The text layer can be checked |
| One reader across several upload paths | Strong | The pattern repeats |
| Tuning on real scans | Mixed | It cannot see your scans' defects |
| Licensing and Linux deployment | Weak | Depends on your key and servers |
For the mixed and weak rows, give the agent real sample scans or your deployment details and review the result more closely.
## What did the prompts produce in a real run?
The three prompts in this guide went to Claude Code in order, against a new .NET 9 console app holding six PNG invoice scans and three image-only scanned PDFs. After the session, an independent Release build and run reproduced every figure below.
| Check | Expected | Read | Confidence |
|---|---|---|---|
| sample-01.pdf | 3016.69 | 3016.69 | 94.84 |
| sample-02.pdf | 6710.24 | 6710.24 | 93.19 |
| sample-03.pdf | 10599.84 | 10599.84 | 96.17 |
| sample-01.pdf, searchable copy | 3016.69 | 3016.69 | Not printed |
| Quickstart, six PNG scans | Six rows | Six rows | 91.62 to 96.16 |
- Each prompt left a clean Release build. The Quickstart picked `IronOcr` 2026.10.2 on its own and hit one compile error, which Claude Code fixed with no hand edits.
- One step ran differently from the page. A typed reply approved the third prompt's plan, in place of the plan dialog.
The [run record](/ocr/csharp/ai-agents/ai/#the-run-record) lists the versions, models, timings and test machine behind this guide and the others in the set.
---
## Troubleshooting
- [Apply a License Key in IronOCR](https://ironsoftware.com/ocr/csharp/troubleshooting/apply-a-license-key-in-ironocr/) if the build succeeds and the first read then throws a licensing exception
- [Improve OCR Accuracy](https://ironsoftware.com/ocr/csharp/troubleshooting/improve-ocr-accuracy/) if a row in the comparison table still fails after a filter change
- [Read Multiple Languages](https://ironsoftware.com/ocr/csharp/how-to/ocr-multiple-languages/) if the agent sets a language the project never installed
## Questions?
If you have any questions, reach out to [support@ironsoftware.com](mailto:support@ironsoftware.com)
Using an AI agent to extract totals from scanned invoices looks simple until a skewed or speckled scan turns a 7 into a 1 and nobody notices before accounts payable does. Claude Code, Anthropic's coding agent, runs in the terminal, in VS Code and JetBrains, as a desktop app, and in the browser. It reads code, edits files, and runs commands, which suits OCR work where the code has to change whenever a value read from a page does not match.
IronOCR runs a tuned Tesseract engine locally, so OCR processing sends no data to external services. Claude Code does send what it reads to the model, including the text your code prints, so develop against sample pages rather than real supplier invoices. Claude Code can write the reader, generate those pages with known values, and compare every result with them before it reports a task done.
Models vary in style. Given the same prompt, two models may choose different class names and structures and agree only on what you specified. State the details that matter, as the prompt section below shows, and let the model decide the rest.
Quickstart
Install with NuGet
PM > Install-Package IronOcr
Install-Package IronOcr
Install IronOCR by running the command above in the NuGet Package Manager Console, or search for the package in the NuGet Package Manager.
Start Claude Code in a .NET project, switch to Sonnet with /model sonnet, and send this prompt.
Add IronOCR (the IronOcr NuGet package) to this project, then read every PNG in@TestData/inbox/ and print one row per file giving the file name, the overallconfidence, and the first line of text. Read the license key from theIRONOCR_LICENSE_KEY environment variable.
Add IronOCR (the IronOcr NuGet package) to this project, then read every PNG in
@TestData/inbox/ and print one row per file giving the file name, the overall
confidence, and the first line of text. Read the license key from the
IRONOCR_LICENSE_KEY environment variable.
Text
If a prompt leaves details open, Claude Code decides them. It keeps your target framework and picks its own names. That is fine for a quick test. For production code, state the IronOCR version in the prompt so the code targets one known API.
Run Claude Code from the project folder so it can see the current code
Write the project's OCR rules into CLAUDE.md for future sessions
Name the target files in each prompt and send larger changes in plan mode
Build after each change and review the printed results
What does Claude Code do in a .NET OCR project?
In an OCR project, Claude Code writes the invoice reader and reads each page. When a total is wrong or a page returns no text, it adjusts the read and tries again. You describe the documents and review the results.
Scan cleanup is built in: IronOCR's input object already provides correction filters, so the agent applies one rather than writing its own image processing.
A maintained engine saves tuning work: a hand-configured Tesseract setup needs testing before you can trust it. The AI coding assistants guide includes a test you can run on your machine.
Each platform has its own package: Intel Macs use IronOcr.MacOs and Apple silicon Macs use IronOcr.MacOs.ARM. An agent that guesses the package can install a look-alike that an attacker published under a name models tend to invent, an attack known as slopsquatting.
How do you set up Claude Code?
Install Claude Code with Anthropic's quickstart and sign in. When it starts and replies, the environment is ready.
How do you set up a project Claude Code can work in?
Create a console project before starting the agent. Claude Code reads CLAUDE.md when each session opens, and one prompt creates the file.
Create CLAUDE.md at the project root with an OCR section stating that thisproject uses IronOCR (NuGet package IronOcr, or IronOcr.Linux for Linux andDocker, namespace IronOcr) for all OCR work, that you must readhttps://ironsoftware.com/ocr/csharp/llms.txt before writing OCR code and use onlyAPIs documented there, that https://ironsoftware.com/ocr/csharp/skill.md shouldbe loaded if the tooling supports skill files, that the license key is read fromthe IRONOCR_LICENSE_KEY environment variable and never inlined, that every OCRchange must be tested on sample pages with known values, and that no other OCRengine or cloud OCR service may be added.
Create CLAUDE.md at the project root with an OCR section stating that this
project uses IronOCR (NuGet package IronOcr, or IronOcr.Linux for Linux and
Docker, namespace IronOcr) for all OCR work, that you must read
https://ironsoftware.com/ocr/csharp/llms.txt before writing OCR code and use only
APIs documented there, that https://ironsoftware.com/ocr/csharp/skill.md should
be loaded if the tooling supports skill files, that the license key is read from
the IRONOCR_LICENSE_KEY environment variable and never inlined, that every OCR
change must be tested on sample pages with known values, and that no other OCR
engine or cloud OCR service may be added.
Text
Settle licensing before the first read. Without a valid key, IronOCR's Read method does not watermark or degrade output. It throws a LicensingException. That type is not public, so have the code check License.IsLicensed at startup instead of catching the exception by name. The IronOCR License Keys page covers getting and storing a key.
How do you prompt for IronOCR code that compiles?
In the terminal, press Shift+Tab until plan mode is on, then send this prompt.
Create Services/InvoiceReader.cs with a method that takes the path of a scanned PDF, reads it with IronTesseract, finds the line that starts with Total due, and returns the amount as a decimal together with that line's confidence, or null if the line is missing. Create Services/SearchablePdf.cs with a method that writes a searchable copy of a scanned PDF. Add a console check that reads three sample invoices with known totals and prints expected total, total read, confidence, and match for each. Use only methods documented at ironsoftware.com/ocr/csharp. If unsure of a method name, stop and ask.
Create Services/InvoiceReader.cs with a method that takes the path of a scanned PDF, reads it with IronTesseract, finds the line that starts with Total due, and returns the amount as a decimal together with that line's confidence, or null if the line is missing. Create Services/SearchablePdf.cs with a method that writes a searchable copy of a scanned PDF. Add a console check that reads three sample invoices with known totals and prints expected total, total read, confidence, and match for each. Use only methods documented at ironsoftware.com/ocr/csharp. If unsure of a method name, stop and ask.
Text
Two details make this prompt work.
Named files: the code lands exactly where you want it.
Confidence: a correct value read at low confidence warns that the next scan may be misread, and the table makes that visible.
The resulting code is short. It creates the engine, loads the PDF inside a using declaration, calls Read, searches the result's lines for the total, and writes the searchable copy with SaveAsSearchablePdf. The scanned PDF input guide and the searchable PDF guide cover both steps.
Watch for one shortcut. IronOCR's skill file offers IronTesseract.ConvertToSearchablePdf for a one-line conversion, and Claude Code reached for it first in both of our tests. On image-only scans it throws "PDF document does not contain any images" in IronOCR 2026.9.4 and 2026.10.2 alike. Claude Code read the error, switched to the approach above, and succeeded.
Which IronOCR settings belong in CLAUDE.md?
Settle three IronOCR decisions there.
Languages:IronOcr.Languages.German stops at 2020.11.2 while the engine releases monthly. IronOCR's multiple languages guide warns that additional languages can affect speed and performance.
Filters: in our probe, adding the two filters named in the rule below to a single-line read of a small crop around the $9,924.31 total reduced it to a lone period.
The read method: the photo method ran in the base IronOCR 2026.9.4 package during our probe, with no extra install, although the photo reading guide still lists IronOcr.Extensions.AdvancedScan as a requirement.
## OCR settings- Languages: English (built in) and German (IronOcr.Languages.German). Language packs keep their own versions. Never align them with IronOcr.- A LanguagePackException names the missing package. Install that package instead of catching the exception.- Add secondary languages in order of how often they appear.- Apply Deskew() and DeNoise() to the whole page before any crop.- Scans use IronTesseract.Read. Photographs of documents use ReadPhoto, which supports fewer languages than Read.- Make searchable copies with Read followed by SaveAsSearchablePdf.
## OCR settings
- Languages: English (built in) and German (IronOcr.Languages.German).
Language packs keep their own versions. Never align them with IronOcr.
- A LanguagePackException names the missing package. Install that package
instead of catching the exception.
- Add secondary languages in order of how often they appear.
- Apply Deskew() and DeNoise() to the whole page before any crop.
- Scans use IronTesseract.Read. Photographs of documents use ReadPhoto,
which supports fewer languages than Read.
- Make searchable copies with Read followed by SaveAsSearchablePdf.
Text
Can Claude Code connect to IronOCR through MCP?
Claude Code can add an MCP server with one command, as the MCP reference explains, but IronOCR does not need one. The documentation index and skill file linked from the project's rule file give the agent the current API, recipes and fixes with nothing to host or restart.
What should you verify before trusting generated OCR code?
Complete these three checks in order after each change.
The build passes: an invented member fails dotnet build, so run it first.
The defaults suit the job: check the settings the code relies on. Configuration.ReadBarCodes is off by default.
Failures are handled: ask for the failure paths by name. The debugging guide covers logging and the exceptions IronOCR raises.
Which OCR tasks suit an agent?
Task
Fit
Why
Searchable PDFs
Strong
The text layer can be checked
One reader across several upload paths
Strong
The pattern repeats
Tuning on real scans
Mixed
It cannot see your scans' defects
Licensing and Linux deployment
Weak
Depends on your key and servers
For the mixed and weak rows, give the agent real sample scans or your deployment details and review the result more closely.
What did the prompts produce in a real run?
The three prompts in this guide went to Claude Code in order, against a new .NET 9 console app holding six PNG invoice scans and three image-only scanned PDFs. After the session, an independent Release build and run reproduced every figure below.
Check
Expected
Read
Confidence
sample-01.pdf
3016.69
3016.69
94.84
sample-02.pdf
6710.24
6710.24
93.19
sample-03.pdf
10599.84
10599.84
96.17
sample-01.pdf, searchable copy
3016.69
3016.69
Not printed
Quickstart, six PNG scans
Six rows
Six rows
91.62 to 96.16
Each prompt left a clean Release build. The Quickstart picked IronOcr 2026.10.2 on its own and hit one compile error, which Claude Code fixed with no hand edits.
One step ran differently from the page. A typed reply approved the third prompt's plan, in place of the plan dialog.
The run record lists the versions, models, timings and test machine behind this guide and the others in the set.
Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.