Call DocuOCR from C# with the built-in HttpClient: POST a PDF or image, start extraction, and read structured JSON back with named fields, tables and confidence scores. No OCR engine to host, no NuGet SDK to wire, no cloud service account.
The same endpoint reads digital and scanned PDFs and images, so one code path handles them all. Copy the C# below and run it against your own document. Last updated July 2026.
Upload a document to extract
Drop files here or click to upload
Up to 50 files
Uploading...
See the JSON your C# would receive, right in the browser.
To run OCR in C#, you send a document to an HTTPS endpoint and read the recognized data back as JSON, all through the HttpClient class that ships with .NET. There is no OCR engine to install, no model to train, and with a REST API like DocuOCR no NuGet package to add. You authenticate with a Bearer API key, POST the file to get a file_id, start an extraction job, then poll or receive a webhook for the result. Because the response is JSON, System.Text.Json deserializes it into a C# record of named fields, table rows and confidence scores you can write straight to a database, a DataTable or an accounting workflow. The same three calls work for a native PDF, a scanned PDF, a photo or a screenshot, so your code does not branch on how the document was made.
Three HttpClient calls, from a file on disk to structured JSON. Swap in your API key from the dashboard and point it at any PDF or image. Runs on .NET 6 or newer.
using System.Net.Http.Headers;
using System.Text.Json;
var apiKey = "YOUR_API_KEY";
const string baseUrl = "https://docuocr.com/api/documents";
using var http = new HttpClient();
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
// 1. Upload the PDF or image, get a file_id
using var form = new MultipartFormDataContent();
form.Add(new ByteArrayContent(File.ReadAllBytes("invoice.pdf")), "file", "invoice.pdf");
var upload = await http.PostAsync($"{baseUrl}/upload", form);
var fileId = JsonDocument.Parse(await upload.Content.ReadAsStringAsync())
.RootElement.GetProperty("file_id").GetString();
// 2. Start extraction, get a job hash
var extract = await http.PostAsJsonAsync($"{baseUrl}/extract", new { file_id = fileId });
var hash = JsonDocument.Parse(await extract.Content.ReadAsStringAsync())
.RootElement.GetProperty("extraction_hash").GetString();
// 3. Poll until the JSON is ready
JsonElement result;
while (true)
{
var res = await http.GetStringAsync($"{baseUrl}/extraction/{hash}");
result = JsonDocument.Parse(res).RootElement;
if (result.GetProperty("status").GetString() == "completed") break;
await Task.Delay(2000);
}
// result.GetProperty("fields") and ("tables") are ready to use
foreach (var field in result.GetProperty("fields").EnumerateArray())
Console.WriteLine($"{field.GetProperty("name")}: {field.GetProperty("value")}");
That is the whole integration. For a production batch, wrap each call in a try or catch block, add a Polly retry policy with exponential backoff on HTTP 429, and register a webhook instead of the polling loop so results arrive as each document finishes. The document OCR API reference covers the full request and response shape.
The cloud providers ship an official .NET SDK; a REST API needs only HttpClient. What you get back differs more than the language does. Package names verified July 2026 on nuget.org.
| OCR API | .NET NuGet package | What it returns | Best for |
|---|---|---|---|
| DocuOCR | None (HttpClient, plain REST) | Named fields, tables and confidence as JSON | Fields plus tables from one call, scans included |
| Google Cloud Vision | Google.Cloud.Vision.V1 | Text and bounding boxes, no named fields | Raw text OCR on the Google stack |
| Google Document AI | Google.Cloud.DocumentAI.V1 | Text plus entities, needs a service account | Google-native document pipelines |
| AWS Textract | AWSSDK.Textract | Text, forms and tables as blocks | AWS-stack teams already using the AWS SDK for .NET |
| Azure AI Document Intelligence | Azure.AI.DocumentIntelligence | Text, layout and prebuilt-model fields | Azure-stack, prebuilt invoice or receipt models |
| Azure Vision (image OCR) | Azure.AI.Vision.ImageAnalysis | Printed and handwritten text from images | Reading photos and screenshots on Azure |
| Mistral Document AI | None official (REST; community Mistral.SDK) | Markdown plus structured output | LLM-based parsing of mixed content |
| Tesseract | Tesseract (charlesw, local, not a hosted API) | Plain text only | Offline, low-volume, no API cost |
The split that matters: raw OCR APIs like Google Cloud Vision return text and coordinates, so you write the field mapping into your own C# model yourself. A document extraction API returns named fields and table rows already, which is most of the code you would otherwise maintain. See the full OCR API pricing comparison for what each costs per 1,000 pages.
Generate a key in the dashboard and send it as a Bearer token on the HttpClient default headers.
POST a PDF, PNG, JPG, TIFF or WEBP as multipart form data and read the file_id from the JSON.
POST the file_id to start an async job and get an extraction_hash back.
Poll or receive a webhook, then System.Text.Json gives you fields, tables and confidence.
A controller or minimal API accepts an upload, posts it to the OCR API, and returns clean structured data to the client with no manual entry.
A .NET worker service pulls invoices from an inbox or blob container, extracts totals and line items, and posts them to Dynamics, QuickBooks or an ERP.
A background job turns scanned statements and reports into rows, then loads them into SQL Server or a DataTable for reporting.
A hosted service classifies and reads documents on upload so the rest of the app receives typed, validated data.
A desktop line-of-business app reads scanned forms and screenshots into fields without shipping an OCR engine to every workstation.
A verification flow reads IDs and forms, checks confidence scores, and routes low-confidence values to a reviewer.
The full endpoint reference and response shape.
Extract text and data from any image with one API.
The same three calls from Python with requests.
The same three calls from Node.js with fetch.
Call the API from Java with the built-in HttpClient.
The same three calls from PHP or Laravel with cURL or Guzzle.
An honest roundup of OCR APIs for US teams.
Pull tables from PDFs to Excel, CSV or JSON.
Per-1,000-page rates across the market.
Generate an API key, paste the three HttpClient calls above, and read structured JSON back in minutes. No engine to host, no NuGet SDK to learn, and a free tier to test the integration before you pay per page.