# Using IronOCR with AI Coding Assistants
IronOCR is a commercial OCR library for .NET with more than six million NuGet downloads. Its tutorials, how-to guides, and troubleshooting notes have been public for years, so coding assistants have usually seen it in their training data.
That familiarity does not extend to which release your project pins. An assistant that reads IronOCR's documentation is more likely to write OCR code that builds and returns accurate text. Share the documentation before the first request.
These tools fall into two categories, which differ in how much they do before you review the result.
- An **assistant** works inside one part of your workflow. It completes a line, explains a method, or makes a small edit, as GitHub Copilot's inline suggestions do.
- An **agent** takes a multi-step task, edits across files, runs the build and the tests, and commits the result for review, as Claude Code, ChatGPT Codex, Cursor, and Google Antigravity do.
The setup is identical for both. Install the package, apply the license key from an environment variable, provide IronOCR's machine-readable documentation, and check every extracted value against a page whose text you already know. This applies to [images](https://ironsoftware.com/ocr/csharp/how-to/input-images/) and [scanned PDFs](https://ironsoftware.com/ocr/csharp/how-to/input-pdfs/) alike, and to [making a scan searchable](https://ironsoftware.com/ocr/csharp/how-to/searchable-pdf/), [reading multiple languages](https://ironsoftware.com/ocr/csharp/how-to/ocr-multiple-languages/), [extracting barcodes from the same read](https://ironsoftware.com/ocr/csharp/how-to/barcodes/), or [improving a low-quality scan](https://ironsoftware.com/ocr/csharp/how-to/image-quality-correction/).
<div class="flex flex-wrap items-center gap-x-14 gap-y-6 py-4">
<img src="/static-assets/svgs/ai-coding-agents/claude.svg" alt="Claude Code AI coding agent logo" width="48" height="48" />
<img src="/static-assets/svgs/ai-coding-agents/codex.svg" alt="ChatGPT Codex AI coding agent logo" width="48" height="48" />
<img src="/static-assets/svgs/ai-coding-agents/github-copilot-black.svg" alt="GitHub Copilot AI coding assistant logo" width="48" height="48" />
<img src="/static-assets/svgs/ai-coding-agents/cursor-black.svg" alt="Cursor AI code editor logo" width="48" height="48" />
<img src="/static-assets/svgs/ai-coding-agents/antigravity.svg" alt="Google Antigravity AI coding agent logo" width="48" height="48" />
</div>
<div class="hsg-featured-snippet">
<h2>How to Use IronOCR with an AI Coding Assistant or Agent</h2>
<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>Load the license key from an environment variable ahead of the first read</li>
<li>Give the assistant IronOCR's <code>llms.txt</code> index before it writes any code</li>
<li>Record the IronOCR rules wherever your assistant keeps project instructions</li>
<li>Begin a fresh session with the one-shot setup prompt below</li>
<li>Compile, then check IronOCR's output against the values you expect on each sample page</li>
</ol>
</div>
<br class="clear" />
## Can't My AI Assistant Handle OCR on Its Own?
Without documentation, an assistant relies on whatever OCR code it absorbed in training, which often mixes in settings from raw Tesseract wrappers or an earlier IronOCR version.
IronOCR publishes documentation built for tools to read, including tutorials, how-to guides, and more than fifty troubleshooting articles. Once the assistant has loaded it, the documentation shows how `IronTesseract`, `OcrInput`, and `OcrResult` fit together.
Engine selection still matters. Free Tesseract wrappers handle a clean, upright page of English well.
- **Readable output does not guarantee correct output:** an OCR result can read fluently and still turn 589.50 into 580.50. `OcrResult` reports a confidence score for every word to show where to look.
- **Scans require preparation:** crooked, noisy, or low-resolution pages read poorly in any engine. `OcrInput` carries filters that straighten a page, remove noise, raise resolution, and more.
- **Hand-tuning an engine is costly:** each attempt an assistant makes at raw Tesseract settings spends tokens on work the library already does, and the cost recurs with every new document type.
- **The package depends on the platform:** `IronOcr` covers Windows, `IronOcr.MacOs` covers Intel Macs, and `IronOcr.MacOs.ARM` covers Apple silicon. An assistant can also invent a plausible package name, and attackers register such names with malicious code, a practice called *slopsquatting*. Name the package in the prompt.
- **Licensing is predictable:** cloud OCR services often bill per page or per call, and an assistant will not mention those terms on its own. IronOCR runs locally under a perpetual commercial license priced in tiers by developers, locations, and projects, with no per-page metering.
<hr class="separator" />
## Step 1: Install IronOCR
Once the package reference exists, the assistant can see IronOCR's actual types as it generates code.
```text
Install the IronOcr NuGet package into this project and confirm it restores.
```
The [advanced NuGet installation guide](https://ironsoftware.com/ocr/csharp/get-started/advanced-installation-nuget/) lists the other installation options.
---
## Step 2: Apply Your License Key
IronOCR has no watermarked unlicensed mode. Constructing an `IronTesseract` without a key succeeds, but the first read throws IronSoftware.Exceptions.LicensingException with the message "Production License Required". A key that is present but mistyped produces "License Key Not Recognized" from the same call. You can get a free trial key below.
!!!--LIBRARY_START_TRIAL_BLOCK--!!!
Set `IronOcr.License.LicenseKey` at application startup, before any other IronOCR call, and read it from the `IRONOCR_LICENSE_KEY` environment variable so that it never enters source control. The same class also has a method that tests a key string without applying it.
[[i:([IronOCR License Keys](https://ironsoftware.com/ocr/csharp/get-started/license-keys/) covers other places to store a key, including `Web.config` and `appsettings.json`.)]]
---
## Step 3: Point Your Assistant at IronOCR's LLM Documentation
- [`llms.txt`](https://ironsoftware.com/ocr/csharp/llms.txt) is the index, one line per page.
- Summaries of 145 pages arrive in one fetch from [`llms-full.txt`](https://ironsoftware.com/ocr/csharp/llms-full.txt).
- [`llms-full-catalog.txt`](https://ironsoftware.com/ocr/csharp/llms-full-catalog.txt) adds the blog to the index.
- The [API Reference](https://ironsoftware.com/ocr/csharp/object-reference/api/) documents every type and member.
- Setup, licensing, recipes, and fixes are in [`skill.md`](https://ironsoftware.com/ocr/csharp/skill.md).
- The [AI Product Fact Sheet](https://ironsoftware.com/ocr/csharp/ai-info/) sums up scope, platforms, and limits.
When a task depends on the detail of one guide, have the assistant open that guide's page.
Provide a direct instruction along with the index.
```text
Before writing any IronOCR code, read https://ironsoftware.com/ocr/csharp/llms.txt
and use only APIs documented there. A read is assembled on an OcrInput, whose
Load overloads differ by source type, and run through IronTesseract.Read.
Confirm the overload you pick against
https://ironsoftware.com/ocr/csharp/object-reference/api/, and if you cannot find
it, say so instead of guessing.
```
---
## Step 4: Add IronOCR Context to Your Project
Place the IronOCR rules in whichever file your team already keeps. Claude Code reads `CLAUDE.md`, GitHub Copilot reads `.github/copilot-instructions.md`, and ChatGPT Codex and Google Antigravity read `AGENTS.md`. Cursor reads `.cursor/rules/*.mdc` or `AGENTS.md`, and only its rule file needs MDC frontmatter. Use the following as a starting point.
```markdown
## OCR with IronOCR
This project uses IronOCR (NuGet package `IronOcr`, or `IronOcr.Linux` for Linux and Docker, namespace `IronOcr`) for all OCR work.
- Reference: https://ironsoftware.com/ocr/csharp/llms.txt
- Skill file: https://ironsoftware.com/ocr/csharp/skill.md
- Read with `IronTesseract` and an `OcrInput` inside a `using` block, and use the `OcrResult` it returns.
- Read the license key from the IRONOCR_LICENSE_KEY environment variable at startup. Never inline it.
- Every OCR change must be tested against sample pages whose text is known, reporting the values read and their confidence.
- Do not add another OCR engine or a cloud OCR service. If IronOCR cannot do something, say so.
```
The skill file's single-file example still pins `IronOcr` 2026.7.2 while NuGet now serves 2026.10.2. It also says to keep every Iron package on the same version, which language packs cannot follow, since `IronOcr.Languages.German` was last published as 2020.11.2. Its one-line `ConvertToSearchablePdf` recipe threw on image-only scanned PDFs in our tests, while loading the PDF, reading it, and calling `SaveAsSearchablePdf` on the result worked.
---
## Step 5: One-Shot Setup Prompt
Everything from Steps 1 through 4 can be sent in a single message.
```text
Use IronOCR for all OCR work in this project.
1. Install the IronOcr NuGet package (IronOcr.Linux when the app runs on Linux or Docker).
2. Apply the license key at application startup, before any other IronOCR call,
reading it from the IRONOCR_LICENSE_KEY environment variable. Never write
the key into source or into a committed file.
3. Read https://ironsoftware.com/ocr/csharp/llms.txt before writing OCR code
and work only from APIs documented there, checking the API reference when a
member is unfamiliar.
4. Load https://ironsoftware.com/ocr/csharp/skill.md if your tooling supports skill files.
5. Keep these instructions for future sessions in this project.
```
---
## Step 6: Prompt Patterns That Produce Working Code
Weak results usually come from a prompt that leaves the assistant room to guess.
Name the input, the fields, and the language.
> **Vague** *Read the invoices with IronOCR.*
>
> **Better** *Using IronTesseract with an OcrInput that loads each scanned PDF, read the invoice number and the line starting with Total due, and return the amount with the confidence of that line.*
State the release and the framework too.
> **Better** *Target .NET 9 with IronOcr 2026.9.4.*
Request the whole file.
> **Better** *Hand back the complete Program.cs, directives and license setup included, ready to compile without edits.*
---
## Step 7: Verify What You Get Back
Watch for these common errors.
- **OCR on a PDF that already has text:** extracting a real text layer is faster and more accurate than running OCR over the pages. Check for a text layer first and run OCR only on scanned pages.
- **Every filter at once:** stacking one correction after another on a clean page can lower accuracy and always adds time. On a dense invoice set in our test runs, `DeNoise` turned the final 1 of a rotated invoice number into a 4, and adding `Dilate` cured that page but cost other sets one to three rows. Apply only the filter that fixes the defect you see. IronOCR's skill file gives the same advice, and the [image quality correction guide](https://ironsoftware.com/ocr/csharp/how-to/image-quality-correction/) describes when each filter applies.
### Let the Agent Verify Its Own Work
```text
Build and run this project in Release. Confirm that every IronOCR member you used
appears in the documentation, that IronOcr.License.IsLicensed returns true, and
that every sample page reads back with the values it is known to contain.
Report the build result and a table of page, expected value, value read, confidence, and match.
```
---
## How Do You Read Languages Other Than English?
English is the only language in the `IronOcr` package. IronOCR's [language list](https://ironsoftware.com/ocr/csharp/languages/) covers 125. Give the assistant these facts.
- Another language needs its pack, such as `IronOcr.Languages.German`, then `Language = OcrLanguage.German`.
- Without NuGet access, use the `.ocrdata` file and `Installation.LanguagePackDirectory`.
- Fast and Best variants such as `OcrLanguage.GermanFast` ship in the same package.
- For a page in several languages, call `AddSecondaryLanguage`, most common first.
- Financial tables take `OcrLanguage.Financial` from `IronOcr.Languages.Financial`.
- A model trained elsewhere loads through `UseCustomTesseractLanguageFile` with a `.traineddata` file.
A missing pack raises LanguagePackException on the first read. Its message names the exact NuGet package and the `.ocrdata` alternative, so have the assistant install what the message names.
IronOCR's [fast configuration guide](https://ironsoftware.com/ocr/csharp/how-to/ocr-fast-configuration/) reports a 17% gain from `EnglishFast` combined with switching barcode reading off. On ten of our pages that variant alone stayed within run-to-run noise of English, so time the variants on your own pages before trading accuracy for speed.
ClickOnce publishing omits the `.ocrdata` files of secondary languages, as the [ClickOnce note](https://ironsoftware.com/ocr/csharp/troubleshooting/clickonce-missing-language-files/) explains. On Windows, adding `EnglishFast` as a secondary language can stall on large PDFs in releases 2025.12.3 through 2026.7.2, as [this troubleshooting entry](https://ironsoftware.com/ocr/csharp/troubleshooting/englishfast-hang-large-pdfs/) records.
---
## Which IronOCR Settings Are On by Default?
Generated code often sets values that are already defaults, or misses a setting that is off by default. These are the starting values in `IronOcr` 2026.9.4, read from a fresh `IronTesseract`.
| Setting | Default | Change it for |
|---|---|---|
| `Language` | English | Other languages |
| `Configuration.ReadBarCodes` | off | Barcodes |
| `Configuration.ReadDataTables` | off | Table structure |
| `Configuration.RenderSearchablePdf` | on | Skipping searchable output |
| `Configuration.RenderHocr` | off | hOCR output |
| `Configuration.PageSegmentationMode` | AutoOsd | Single-line or single-word crops |
| `Configuration.EngineMode` | LstmOnly | Rarely |
| `Configuration.WhiteListCharacters` and `BlackListCharacters` | empty | Narrow character sets |
| `Configuration.TesseractVariables` | three preset entries | Raw Tesseract variables |
| `MultiThreaded` | on | Rarely |
| `MaxDegreeOfParallelism` | Environment.ProcessorCount | Large batches short of memory |
| `OcrInput.TargetDPI` | 0 | Low-resolution scans |
Beyond the standard read, `IronTesseract` provides readers tuned for other input. `ReadPhoto` handles photographs of documents and `ReadScreenShot` handles screen captures. The [specialized documents tutorial](https://ironsoftware.com/ocr/csharp/tutorials/read-specific-document/) still lists `IronOcr.Extensions.AdvancedScan` for them, but that package last shipped in 2025 and neither reader needed it. The same tutorial also covers the passport and license plate readers.
---
## A Result You Can Reproduce
[[i:(Running the prompt requires a new session, the .NET SDK, a network connection, an assistant with terminal access, and an IronOCR trial or production key.)]]
### The prompt
```text
Build a .NET 9 console app that reads totals from scanned invoices. Start in an empty folder; if it already holds code or project files, stop and report. Work start to finish alone: write, build, run, and fix, making sensible assumptions where anything is unspecified. Save every deliverable under the project root, in the folders named below.
1. Install the IronOcr NuGet package pinned to version 2026.9.4.
2. Read https://ironsoftware.com/ocr/csharp/llms.txt and the pages it links to, and use only IronOCR APIs documented there for the OCR work. Any .NET imaging library may draw the test images.
3. Read the license key from the IRONOCR_LICENSE_KEY environment variable at startup and never write it into source or any output file. If IronOcr.License.IsLicensed is false, stop and report that.
4. With random seed 2026, generate testset/invoice-01.png to invoice-10.png. Each is a US Letter page of exactly 1700 x 2200 pixels, saved as PNG with 200 DPI in the file metadata, with all text in Arial inside 0.75 inch margins, headings at 14 point bold and everything else at 11 point. Each invoice has an invoice number made of INV- and six random digits, a customer name, three line items with random prices in dollars and cents, and a total equal to their sum, with no two totals alike.
5. Rotate invoice-02 and invoice-07 by 3 degrees about the page center, keeping the 1700 x 2200 canvas. Add speckle noise to invoice-04 and invoice-09: dark square specks 1 or 2 pixels wide, placed anywhere including over the text, until they have darkened 1% of the page's pixels, counting a pixel as dark below 128 of 255. Leave the other six clean. Write manifest.csv with each file, invoice number, the three prices, total, and distortion (none, rotated, or speckled).
6. Before the first OCR call, check every saved image: 1700 x 2200 pixels, 200 DPI when rounded, and, measured on each page before distortion, the smallest distance from any ink to an edge, at least 0.75 inch. On each speckled page, check that speckling raised the share of dark pixels by 0.9 to 1.1 percentage points. Also draw a capital H with the 11 point font on a 200 DPI bitmap and check that its ink is 21 to 23 pixels tall. If a check fails, fix the generator. After the first OCR call, never regenerate or change the saved image files; filters applied in memory are expected.
7. Read all 10 images in one OcrInput with one set of filters for every page. Each run of the program uses one filter set; it must not try several or choose between them, and choosing filters is your job between runs. No manifest value, file name, or expected value may steer the OCR or the parsing of its text; read the manifest only to write roundtrip.md. The reader must hold no invoice number, price, or total as a literal and must run the same code for every page. Extract each page's invoice number and total, save each page's OCR text as ocr/invoice-01.txt to invoice-10.txt, and save the result as invoices-searchable.pdf.
8. Build in Release and run.
9. Write roundtrip.md: the step 6 checks as measured numbers for every image, not pass or fail words, the filter set used, then a table of file, distortion, expected invoice number, invoice number read, expected total, total read, the Confidence (0 to 100) of the OCR line holding the total or n/a, and match, then the page count of invoices-searchable.pdf loaded back with OcrInput. A row matches only when the invoice number read is identical to the expected one and the total read equals the expected total to the cent.
10. All 10 rows must match and the PDF must have 10 pages. If not, read the saved OCR text of the failing pages, change the filter set or the reader, rebuild, and run again. If rows still fail after eight such runs, stop and report which rows failed, the filter sets tried, and why.
11. Finish with a short report: build result, match count, filters used, font sizes used, and assumptions made.
```
### Output
<img src="/static-assets/ocr/ai-agents/ai/invoice-display.png" alt="Speckled test invoice that IronOCR read correctly in the acceptance test run" width="564" height="444" loading="lazy" />
This is invoice-09, one of the two speckled pages from the run, cropped to the printed area. A plain read matched 8 of 10 invoices and missed both speckled pages, returning this one's invoice number as ANV-938066, and `Deskew` alone did no better. With `DeNoise` added, IronOCR returned INV-939066 and 1731.53, at 41.45 confidence on the total line, the lowest of the run. The other speckled total line read at 63.86 and the clean pages at about 95. Claude Code chose those two filters in its first draft and kept them through all five runs of the program.
- An independent check measured every requirement again, and all 10 invoices matched.
- ChatGPT Codex with GPT-6 Luna also matched 10 of 10 on the same prompt.
- [`roundtrip.md`](/static-assets/ocr/ai-agents/ai/roundtrip.md) is published unedited and [invoice.png](/static-assets/ocr/ai-agents/ai/invoice.png) at reduced size.
### What passes
- The code needed no edits from you.
- Opening any image shows small text with nothing cut off at the edges, and specks on the text as well as the margins.
- Each invoice number and total in `roundtrip.md` also appears in that page's saved OCR text.
[[i:(The [IronOCR changelog](https://ironsoftware.com/ocr/csharp/product-updates/changelog/) lists what each release changed.)]]
### The run record
- The machine runs Windows 11 x64 on a Core i9-14900KF with 64 GB of memory.
- Every project targets .NET 9.
- This guide, Copilot, and Cursor ran `IronOcr` 2026.9.4, while Claude Code, Codex, and Antigravity ran 2026.10.2. Copilot added `IronOcr.Linux` 2026.9.4, and Codex, Cursor, and Antigravity added `IronOcr.Languages.German` 2020.11.2.
- **Last tested** October 8, 2026, with the Cursor run. Every other run is from October 6.
| Guide | Assistant and version | Model | Duration (minutes) |
|---|---|---|---|
| This guide | Claude Code 2.1.277, permission prompts off | Claude Opus 5 | 20.8 |
| [Claude Code](https://ironsoftware.com/ocr/csharp/ai-agents/claude-code/) | Claude Code 2.1.277 | Claude Sonnet 5 | 9.4 |
| [ChatGPT Codex](https://ironsoftware.com/ocr/csharp/ai-agents/chatgpt-codex/) | Codex CLI 0.160.0 | GPT-6 Luna | 27.7 |
| [GitHub Copilot](https://ironsoftware.com/ocr/csharp/ai-agents/github-copilot/) | Copilot agent mode in VS Code 1.140 | GPT-6 Luna, routed by Auto | 22.0 |
| [Cursor](https://ironsoftware.com/ocr/csharp/ai-agents/cursor/) | Cursor 3.23.23 desktop app | Grok 4.7 | 83.5 |
| [Google Antigravity](https://ironsoftware.com/ocr/csharp/ai-agents/antigravity/) | Antigravity CLI 1.3.0 | Gemini 3.8 Flash (High) | 32.7 |
---
## Agent-Specific Guides
For steps that suit one tool, open its guide.
- [Use IronOCR with Claude Code](https://ironsoftware.com/ocr/csharp/ai-agents/claude-code/)
- [Use IronOCR with ChatGPT Codex](https://ironsoftware.com/ocr/csharp/ai-agents/chatgpt-codex/)
- [Use IronOCR with GitHub Copilot](https://ironsoftware.com/ocr/csharp/ai-agents/github-copilot/)
- [Use IronOCR with Cursor](https://ironsoftware.com/ocr/csharp/ai-agents/cursor/)
- [Use IronOCR with Google Antigravity](https://ironsoftware.com/ocr/csharp/ai-agents/antigravity/)
---
## Troubleshooting
- [Apply a License Key in IronOCR](https://ironsoftware.com/ocr/csharp/troubleshooting/apply-a-license-key-in-ironocr/)
- [Improve OCR Accuracy](https://ironsoftware.com/ocr/csharp/troubleshooting/improve-ocr-accuracy/) if the recognized text does not match the page
- [General OCR Troubleshooting](https://ironsoftware.com/ocr/csharp/troubleshooting/general-troubleshooting-ocr/) if errors appear after deployment
---
## Questions?
If you have any questions, reach out to [support@ironsoftware.com](mailto:support@ironsoftware.com)
IronOCR is a commercial OCR library for .NET with more than six million NuGet downloads. Its tutorials, how-to guides, and troubleshooting notes have been public for years, so coding assistants have usually seen it in their training data.
That familiarity does not extend to which release your project pins. An assistant that reads IronOCR's documentation is more likely to write OCR code that builds and returns accurate text. Share the documentation before the first request.
These tools fall into two categories, which differ in how much they do before you review the result.
An assistant works inside one part of your workflow. It completes a line, explains a method, or makes a small edit, as GitHub Copilot's inline suggestions do.
An agent takes a multi-step task, edits across files, runs the build and the tests, and commits the result for review, as Claude Code, ChatGPT Codex, Cursor, and Google Antigravity do.
Load the license key from an environment variable ahead of the first read
Give the assistant IronOCR's llms.txt index before it writes any code
Record the IronOCR rules wherever your assistant keeps project instructions
Begin a fresh session with the one-shot setup prompt below
Compile, then check IronOCR's output against the values you expect on each sample page
Can't My AI Assistant Handle OCR on Its Own?
Without documentation, an assistant relies on whatever OCR code it absorbed in training, which often mixes in settings from raw Tesseract wrappers or an earlier IronOCR version.
IronOCR publishes documentation built for tools to read, including tutorials, how-to guides, and more than fifty troubleshooting articles. Once the assistant has loaded it, the documentation shows how IronTesseract, OcrInput, and OcrResult fit together.
Engine selection still matters. Free Tesseract wrappers handle a clean, upright page of English well.
Readable output does not guarantee correct output: an OCR result can read fluently and still turn 589.50 into 580.50. OcrResult reports a confidence score for every word to show where to look.
Scans require preparation: crooked, noisy, or low-resolution pages read poorly in any engine. OcrInput carries filters that straighten a page, remove noise, raise resolution, and more.
Hand-tuning an engine is costly: each attempt an assistant makes at raw Tesseract settings spends tokens on work the library already does, and the cost recurs with every new document type.
The package depends on the platform:IronOcr covers Windows, IronOcr.MacOs covers Intel Macs, and IronOcr.MacOs.ARM covers Apple silicon. An assistant can also invent a plausible package name, and attackers register such names with malicious code, a practice called slopsquatting. Name the package in the prompt.
Licensing is predictable: cloud OCR services often bill per page or per call, and an assistant will not mention those terms on its own. IronOCR runs locally under a perpetual commercial license priced in tiers by developers, locations, and projects, with no per-page metering.
Step 1: Install IronOCR
Once the package reference exists, the assistant can see IronOCR's actual types as it generates code.
Install the IronOcr NuGet package into this project and confirm it restores.
Install the IronOcr NuGet package into this project and confirm it restores.
IronOCR has no watermarked unlicensed mode. Constructing an IronTesseract without a key succeeds, but the first read throws IronSoftware.Exceptions.LicensingException with the message "Production License Required". A key that is present but mistyped produces "License Key Not Recognized" from the same call. You can get a free trial key below.
Start using IronOCR in your project today with a free trial.
First Step:
Set IronOcr.License.LicenseKey at application startup, before any other IronOCR call, and read it from the IRONOCR_LICENSE_KEY environment variable so that it never enters source control. The same class also has a method that tests a key string without applying it.
Please note: IronOCR License Keys covers other places to store a key, including Web.config and appsettings.json.
Step 3: Point Your Assistant at IronOCR's LLM Documentation
When a task depends on the detail of one guide, have the assistant open that guide's page.
Provide a direct instruction along with the index.
Before writing any IronOCR code, read https://ironsoftware.com/ocr/csharp/llms.txtand use only APIs documented there. A read is assembled on an OcrInput, whoseLoad overloads differ by source type, and run through IronTesseract.Read.Confirm the overload you pick againsthttps://ironsoftware.com/ocr/csharp/object-reference/api/, and if you cannot findit, say so instead of guessing.
Before writing any IronOCR code, read https://ironsoftware.com/ocr/csharp/llms.txt
and use only APIs documented there. A read is assembled on an OcrInput, whose
Load overloads differ by source type, and run through IronTesseract.Read.
Confirm the overload you pick against
https://ironsoftware.com/ocr/csharp/object-reference/api/, and if you cannot find
it, say so instead of guessing.
Text
Step 4: Add IronOCR Context to Your Project
Place the IronOCR rules in whichever file your team already keeps. Claude Code reads CLAUDE.md, GitHub Copilot reads .github/copilot-instructions.md, and ChatGPT Codex and Google Antigravity read AGENTS.md. Cursor reads .cursor/rules/*.mdc or AGENTS.md, and only its rule file needs MDC frontmatter. Use the following as a starting point.
## OCR with IronOCRThis project uses IronOCR (NuGet package `IronOcr`, or `IronOcr.Linux` for Linux and Docker, namespace `IronOcr`) for all OCR work.- Reference: https://ironsoftware.com/ocr/csharp/llms.txt- Skill file: https://ironsoftware.com/ocr/csharp/skill.md- Read with `IronTesseract` and an `OcrInput` inside a `using` block, and use the `OcrResult` it returns.- Read the license key from the IRONOCR_LICENSE_KEY environment variable at startup. Never inline it.- Every OCR change must be tested against sample pages whose text is known, reporting the values read and their confidence.- Do not add another OCR engine or a cloud OCR service. If IronOCR cannot do something, say so.
## OCR with IronOCR
This project uses IronOCR (NuGet package `IronOcr`, or `IronOcr.Linux` for Linux and Docker, namespace `IronOcr`) for all OCR work.
- Reference: https://ironsoftware.com/ocr/csharp/llms.txt
- Skill file: https://ironsoftware.com/ocr/csharp/skill.md
- Read with `IronTesseract` and an `OcrInput` inside a `using` block, and use the `OcrResult` it returns.
- Read the license key from the IRONOCR_LICENSE_KEY environment variable at startup. Never inline it.
- Every OCR change must be tested against sample pages whose text is known, reporting the values read and their confidence.
- Do not add another OCR engine or a cloud OCR service. If IronOCR cannot do something, say so.
Text
The skill file's single-file example still pins IronOcr 2026.7.2 while NuGet now serves 2026.10.2. It also says to keep every Iron package on the same version, which language packs cannot follow, since IronOcr.Languages.German was last published as 2020.11.2. Its one-line ConvertToSearchablePdf recipe threw on image-only scanned PDFs in our tests, while loading the PDF, reading it, and calling SaveAsSearchablePdf on the result worked.
Step 5: One-Shot Setup Prompt
Everything from Steps 1 through 4 can be sent in a single message.
Use IronOCR for all OCR work in this project.1. Install the IronOcr NuGet package (IronOcr.Linux when the app runs on Linux or Docker).2. Apply the license key at application startup, before any other IronOCR call, reading it from the IRONOCR_LICENSE_KEY environment variable. Never write the key into source or into a committed file.3. Read https://ironsoftware.com/ocr/csharp/llms.txt before writing OCR code and work only from APIs documented there, checking the API reference when a member is unfamiliar.4. Load https://ironsoftware.com/ocr/csharp/skill.md if your tooling supports skill files.5. Keep these instructions for future sessions in this project.
Use IronOCR for all OCR work in this project.
1. Install the IronOcr NuGet package (IronOcr.Linux when the app runs on Linux or Docker).
2. Apply the license key at application startup, before any other IronOCR call,
reading it from the IRONOCR_LICENSE_KEY environment variable. Never write
the key into source or into a committed file.
3. Read https://ironsoftware.com/ocr/csharp/llms.txt before writing OCR code
and work only from APIs documented there, checking the API reference when a
member is unfamiliar.
4. Load https://ironsoftware.com/ocr/csharp/skill.md if your tooling supports skill files.
5. Keep these instructions for future sessions in this project.
Text
Step 6: Prompt Patterns That Produce Working Code
Weak results usually come from a prompt that leaves the assistant room to guess.
Name the input, the fields, and the language.
VagueRead the invoices with IronOCR.
BetterUsing IronTesseract with an OcrInput that loads each scanned PDF, read the invoice number and the line starting with Total due, and return the amount with the confidence of that line.
State the release and the framework too.
BetterTarget .NET 9 with IronOcr 2026.9.4.
Request the whole file.
BetterHand back the complete Program.cs, directives and license setup included, ready to compile without edits.
Step 7: Verify What You Get Back
Watch for these common errors.
OCR on a PDF that already has text: extracting a real text layer is faster and more accurate than running OCR over the pages. Check for a text layer first and run OCR only on scanned pages.
Every filter at once: stacking one correction after another on a clean page can lower accuracy and always adds time. On a dense invoice set in our test runs, DeNoise turned the final 1 of a rotated invoice number into a 4, and adding Dilate cured that page but cost other sets one to three rows. Apply only the filter that fixes the defect you see. IronOCR's skill file gives the same advice, and the image quality correction guide describes when each filter applies.
Let the Agent Verify Its Own Work
Build and run this project in Release. Confirm that every IronOCR member you usedappears in the documentation, that IronOcr.License.IsLicensed returns true, andthat every sample page reads back with the values it is known to contain.Report the build result and a table of page, expected value, value read, confidence, and match.
Build and run this project in Release. Confirm that every IronOCR member you used
appears in the documentation, that IronOcr.License.IsLicensed returns true, and
that every sample page reads back with the values it is known to contain.
Report the build result and a table of page, expected value, value read, confidence, and match.
Text
How Do You Read Languages Other Than English?
English is the only language in the IronOcr package. IronOCR's language list covers 125. Give the assistant these facts.
Another language needs its pack, such as IronOcr.Languages.German, then Language = OcrLanguage.German.
Without NuGet access, use the .ocrdata file and Installation.LanguagePackDirectory.
Fast and Best variants such as OcrLanguage.GermanFast ship in the same package.
For a page in several languages, call AddSecondaryLanguage, most common first.
Financial tables take OcrLanguage.Financial from IronOcr.Languages.Financial.
A model trained elsewhere loads through UseCustomTesseractLanguageFile with a .traineddata file.
A missing pack raises LanguagePackException on the first read. Its message names the exact NuGet package and the .ocrdata alternative, so have the assistant install what the message names.
IronOCR's fast configuration guide reports a 17% gain from EnglishFast combined with switching barcode reading off. On ten of our pages that variant alone stayed within run-to-run noise of English, so time the variants on your own pages before trading accuracy for speed.
ClickOnce publishing omits the .ocrdata files of secondary languages, as the ClickOnce note explains. On Windows, adding EnglishFast as a secondary language can stall on large PDFs in releases 2025.12.3 through 2026.7.2, as this troubleshooting entry records.
Which IronOCR Settings Are On by Default?
Generated code often sets values that are already defaults, or misses a setting that is off by default. These are the starting values in IronOcr 2026.9.4, read from a fresh IronTesseract.
Setting
Default
Change it for
Language
English
Other languages
Configuration.ReadBarCodes
off
Barcodes
Configuration.ReadDataTables
off
Table structure
Configuration.RenderSearchablePdf
on
Skipping searchable output
Configuration.RenderHocr
off
hOCR output
Configuration.PageSegmentationMode
AutoOsd
Single-line or single-word crops
Configuration.EngineMode
LstmOnly
Rarely
Configuration.WhiteListCharacters and BlackListCharacters
empty
Narrow character sets
Configuration.TesseractVariables
three preset entries
Raw Tesseract variables
MultiThreaded
on
Rarely
MaxDegreeOfParallelism
Environment.ProcessorCount
Large batches short of memory
OcrInput.TargetDPI
0
Low-resolution scans
Beyond the standard read, IronTesseract provides readers tuned for other input. ReadPhoto handles photographs of documents and ReadScreenShot handles screen captures. The specialized documents tutorial still lists IronOcr.Extensions.AdvancedScan for them, but that package last shipped in 2025 and neither reader needed it. The same tutorial also covers the passport and license plate readers.
A Result You Can Reproduce
Please note: Running the prompt requires a new session, the .NET SDK, a network connection, an assistant with terminal access, and an IronOCR trial or production key.
The prompt
Build a .NET 9 console app that reads totals from scanned invoices. Start in an empty folder; if it already holds code or project files, stop and report. Work start to finish alone: write, build, run, and fix, making sensible assumptions where anything is unspecified. Save every deliverable under the project root, in the folders named below.1. Install the IronOcr NuGet package pinned to version 2026.9.4.2. Read https://ironsoftware.com/ocr/csharp/llms.txt and the pages it links to, and use only IronOCR APIs documented there for the OCR work. Any .NET imaging library may draw the test images.3. Read the license key from the IRONOCR_LICENSE_KEY environment variable at startup and never write it into source or any output file. If IronOcr.License.IsLicensed is false, stop and report that.4. With random seed 2026, generate testset/invoice-01.png to invoice-10.png. Each is a US Letter page of exactly 1700 x 2200 pixels, saved as PNG with 200 DPI in the file metadata, with all text in Arial inside 0.75 inch margins, headings at 14 point bold and everything else at 11 point. Each invoice has an invoice number made of INV- and six random digits, a customer name, three line items with random prices in dollars and cents, and a total equal to their sum, with no two totals alike.5. Rotate invoice-02 and invoice-07 by 3 degrees about the page center, keeping the 1700 x 2200 canvas. Add speckle noise to invoice-04 and invoice-09: dark square specks 1 or 2 pixels wide, placed anywhere including over the text, until they have darkened 1% of the page's pixels, counting a pixel as dark below 128 of 255. Leave the other six clean. Write manifest.csv with each file, invoice number, the three prices, total, and distortion (none, rotated, or speckled).6. Before the first OCR call, check every saved image: 1700 x 2200 pixels, 200 DPI when rounded, and, measured on each page before distortion, the smallest distance from any ink to an edge, at least 0.75 inch. On each speckled page, check that speckling raised the share of dark pixels by 0.9 to 1.1 percentage points. Also draw a capital H with the 11 point font on a 200 DPI bitmap and check that its ink is 21 to 23 pixels tall. If a check fails, fix the generator. After the first OCR call, never regenerate or change the saved image files; filters applied in memory are expected.7. Read all 10 images in one OcrInput with one set of filters for every page. Each run of the program uses one filter set; it must not try several or choose between them, and choosing filters is your job between runs. No manifest value, file name, or expected value may steer the OCR or the parsing of its text; read the manifest only to write roundtrip.md. The reader must hold no invoice number, price, or total as a literal and must run the same code for every page. Extract each page's invoice number and total, save each page's OCR text as ocr/invoice-01.txt to invoice-10.txt, and save the result as invoices-searchable.pdf.8. Build in Release and run.9. Write roundtrip.md: the step 6 checks as measured numbers for every image, not pass or fail words, the filter set used, then a table of file, distortion, expected invoice number, invoice number read, expected total, total read, the Confidence (0 to 100) of the OCR line holding the total or n/a, and match, then the page count of invoices-searchable.pdf loaded back with OcrInput. A row matches only when the invoice number read is identical to the expected one and the total read equals the expected total to the cent.10. All 10 rows must match and the PDF must have 10 pages. If not, read the saved OCR text of the failing pages, change the filter set or the reader, rebuild, and run again. If rows still fail after eight such runs, stop and report which rows failed, the filter sets tried, and why.11. Finish with a short report: build result, match count, filters used, font sizes used, and assumptions made.
Build a .NET 9 console app that reads totals from scanned invoices. Start in an empty folder; if it already holds code or project files, stop and report. Work start to finish alone: write, build, run, and fix, making sensible assumptions where anything is unspecified. Save every deliverable under the project root, in the folders named below.
1. Install the IronOcr NuGet package pinned to version 2026.9.4.
2. Read https://ironsoftware.com/ocr/csharp/llms.txt and the pages it links to, and use only IronOCR APIs documented there for the OCR work. Any .NET imaging library may draw the test images.
3. Read the license key from the IRONOCR_LICENSE_KEY environment variable at startup and never write it into source or any output file. If IronOcr.License.IsLicensed is false, stop and report that.
4. With random seed 2026, generate testset/invoice-01.png to invoice-10.png. Each is a US Letter page of exactly 1700 x 2200 pixels, saved as PNG with 200 DPI in the file metadata, with all text in Arial inside 0.75 inch margins, headings at 14 point bold and everything else at 11 point. Each invoice has an invoice number made of INV- and six random digits, a customer name, three line items with random prices in dollars and cents, and a total equal to their sum, with no two totals alike.
5. Rotate invoice-02 and invoice-07 by 3 degrees about the page center, keeping the 1700 x 2200 canvas. Add speckle noise to invoice-04 and invoice-09: dark square specks 1 or 2 pixels wide, placed anywhere including over the text, until they have darkened 1% of the page's pixels, counting a pixel as dark below 128 of 255. Leave the other six clean. Write manifest.csv with each file, invoice number, the three prices, total, and distortion (none, rotated, or speckled).
6. Before the first OCR call, check every saved image: 1700 x 2200 pixels, 200 DPI when rounded, and, measured on each page before distortion, the smallest distance from any ink to an edge, at least 0.75 inch. On each speckled page, check that speckling raised the share of dark pixels by 0.9 to 1.1 percentage points. Also draw a capital H with the 11 point font on a 200 DPI bitmap and check that its ink is 21 to 23 pixels tall. If a check fails, fix the generator. After the first OCR call, never regenerate or change the saved image files; filters applied in memory are expected.
7. Read all 10 images in one OcrInput with one set of filters for every page. Each run of the program uses one filter set; it must not try several or choose between them, and choosing filters is your job between runs. No manifest value, file name, or expected value may steer the OCR or the parsing of its text; read the manifest only to write roundtrip.md. The reader must hold no invoice number, price, or total as a literal and must run the same code for every page. Extract each page's invoice number and total, save each page's OCR text as ocr/invoice-01.txt to invoice-10.txt, and save the result as invoices-searchable.pdf.
8. Build in Release and run.
9. Write roundtrip.md: the step 6 checks as measured numbers for every image, not pass or fail words, the filter set used, then a table of file, distortion, expected invoice number, invoice number read, expected total, total read, the Confidence (0 to 100) of the OCR line holding the total or n/a, and match, then the page count of invoices-searchable.pdf loaded back with OcrInput. A row matches only when the invoice number read is identical to the expected one and the total read equals the expected total to the cent.
10. All 10 rows must match and the PDF must have 10 pages. If not, read the saved OCR text of the failing pages, change the filter set or the reader, rebuild, and run again. If rows still fail after eight such runs, stop and report which rows failed, the filter sets tried, and why.
11. Finish with a short report: build result, match count, filters used, font sizes used, and assumptions made.
Text
Output
This is invoice-09, one of the two speckled pages from the run, cropped to the printed area. A plain read matched 8 of 10 invoices and missed both speckled pages, returning this one's invoice number as ANV-938066, and Deskew alone did no better. With DeNoise added, IronOCR returned INV-939066 and 1731.53, at 41.45 confidence on the total line, the lowest of the run. The other speckled total line read at 63.86 and the clean pages at about 95. Claude Code chose those two filters in its first draft and kept them through all five runs of the program.
An independent check measured every requirement again, and all 10 invoices matched.
ChatGPT Codex with GPT-6 Luna also matched 10 of 10 on the same prompt.
The machine runs Windows 11 x64 on a Core i9-14900KF with 64 GB of memory.
Every project targets .NET 9.
This guide, Copilot, and Cursor ran IronOcr 2026.9.4, while Claude Code, Codex, and Antigravity ran 2026.10.2. Copilot added IronOcr.Linux 2026.9.4, and Codex, Cursor, and Antigravity added IronOcr.Languages.German 2020.11.2.
Last tested October 8, 2026, with the Cursor run. Every other run is from October 6.
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.