IRONSOFTWAREHOME

Using IronOCR with AI Coding Assistants

Curtis Chau
Curtis Chau
Updated: October 9, 2026

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 and scanned PDFs alike, and to making a scan searchable, reading multiple languages, extracting barcodes from the same read, or improving a low-quality scan.

Claude Code AI coding agent logoChatGPT Codex AI coding agent logoGitHub Copilot AI coding assistant logoCursor AI code editor logoGoogle Antigravity AI coding agent logo

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.
Text

The advanced NuGet installation guide 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.

Start using IronOCR in your project today with a free trial.

First Step:
arrow pointer

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.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 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.
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.

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 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 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.

SettingDefaultChange it for
LanguageEnglishOther languages
Configuration.ReadBarCodesoffBarcodes
Configuration.ReadDataTablesoffTable structure
Configuration.RenderSearchablePdfonSkipping searchable output
Configuration.RenderHocroffhOCR output
Configuration.PageSegmentationModeAutoOsdSingle-line or single-word crops
Configuration.EngineModeLstmOnlyRarely
Configuration.WhiteListCharacters and BlackListCharactersemptyNarrow character sets
Configuration.TesseractVariablesthree preset entriesRaw Tesseract variables
MultiThreadedonRarely
MaxDegreeOfParallelismEnvironment.ProcessorCountLarge batches short of memory
OcrInput.TargetDPI0Low-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.
Text

Output

Speckled test invoice that IronOCR read correctly in the acceptance test run

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 is published unedited and 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.
Please note: The IronOCR 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.
GuideAssistant and versionModelDuration (minutes)
This guideClaude Code 2.1.277, permission prompts offClaude Opus 520.8
Claude CodeClaude Code 2.1.277Claude Sonnet 59.4
ChatGPT CodexCodex CLI 0.160.0GPT-6 Luna27.7
GitHub CopilotCopilot agent mode in VS Code 1.140GPT-6 Luna, routed by Auto22.0
CursorCursor 3.23.23 desktop appGrok 4.783.5
Google AntigravityAntigravity CLI 1.3.0Gemini 3.8 Flash (High)32.7

Agent-Specific Guides

For steps that suit one tool, open its guide.


Troubleshooting


Questions?

If you have any questions, reach out to support@ironsoftware.com

Curtis Chau
Technical Writer

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.

...
Read More

Ready to Get Started?

Nuget Downloads 6,279,416Version:2026.10just released

Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.10

PM > Install-Package IronOcr
nuget.org/packages/IronOcr/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronOCR"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.10

or download Windows Installer here.

  1. Download and unzip IronOCR to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronOCR.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronOCR
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get a Quote, No Obligation
Your details will always be kept confidential.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Trusted by Millions of Engineers Worldwide
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.10

PM > Install-Package IronOcr
nuget.org/packages/IronOcr/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronOCR"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.10

or download Windows Installer here.

  1. Download and unzip IronOCR to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronOCR.dll"

Licenses from $999