CK-PDFExtractor.Core
0.1.0-preview.7
dotnet add package CK-PDFExtractor.Core --version 0.1.0-preview.7
NuGet\Install-Package CK-PDFExtractor.Core -Version 0.1.0-preview.7
<PackageReference Include="CK-PDFExtractor.Core" Version="0.1.0-preview.7" />
<PackageVersion Include="CK-PDFExtractor.Core" Version="0.1.0-preview.7" />
<PackageReference Include="CK-PDFExtractor.Core" />
paket add CK-PDFExtractor.Core --version 0.1.0-preview.7
#r "nuget: CK-PDFExtractor.Core, 0.1.0-preview.7"
#:package CK-PDFExtractor.Core@0.1.0-preview.7
#addin nuget:?package=CK-PDFExtractor.Core&version=0.1.0-preview.7&prerelease
#tool nuget:?package=CK-PDFExtractor.Core&version=0.1.0-preview.7&prerelease
CK-PDFExtractor.Core
Read text and form fields from PDF files in pure .NET. No Python, nothing else to install.
- With a template JSON: reads the boxes you define and returns each value with its confidence.
- Without a template: returns all the text in the document.
- You choose the mode on every call.
Status:
0.1.0-preview.6(prerelease, APIs may change). Requires .NET 10 and Windows x64. No internet access is needed at any point — the OCR model ships inside the package and is unpacked to a local cache on first use, so only the first call pays a small extra startup cost.
How it works
PDF -> pictures -> line up with reference picture -> cut out each box -> read text (OCR) -> remove label -> check pattern -> result
Without a template it skips the middle steps and reads the whole page.
Quick start
using CK.PDFExtractor.Core;
using CK.PDFExtractor.Core.Services;
using Microsoft.Extensions.DependencyInjection;
var services = new ServiceCollection();
services.AddLogging();
services.AddReceiptExtractionWithSdcb();
using var provider = services.BuildServiceProvider();
using var scope = provider.CreateScope();
var extractor = scope.ServiceProvider.GetRequiredService<ReceiptExtractionService>();
byte[] pdf = await File.ReadAllBytesAsync("document.pdf");
var result = await extractor.ExtractAsync(pdf, "template.json"); // with a template
var all = await extractor.ExtractAsync(pdf, null); // whole document
foreach (var f in result.Fields)
Console.WriteLine($"{f.FieldName} = '{f.RawValue}' ({f.OcrConfidence:F3}) {f.ValidationMessage}");
Sample template.json
{
"Version": 2,
"CanonicalTemplatePath": "reference.png",
"CanonicalDimensions": { "Width": 1200, "Height": 1600 },
"Fields": [
{
"FieldName": "ENGINE_NUMBER",
"FieldType": "Text",
"Region": { "X1": 316, "Y1": 656, "X2": 550, "Y2": 719 },
"Pattern": "^[0-9A-Z]{14}$",
"Required": true,
"PageNumber": 1
}
]
}
CanonicalTemplatePathis a picture of the blank form, next to the JSON.Regionis in that picture's pixels.- Each box must hold only the printed label and its value.
FieldNamemust match the printed label (case,_and spaces are ignored), which is how the label is removed. Patternis a regex. A mismatch is flagged, not discarded.Required: truedoes not make the call fail.- Several pages in one JSON: set each field's
PageNumberand add"PageTemplates": [ { "PageNumber": 2, "CanonicalTemplatePath": "page2.png" } ]for every page after page 1 (page 1 uses the top-level picture).
Template calibration GUI
A calibration GUI for drawing the boxes and generating the template JSON and reference pictures is provided by the author. It is not part of the NuGet package. Ask the author for it.
Sample results
Read Status first. If it is Failed, read Errors. Otherwise check each field. Success only means the pipeline ran, not that every field was found.
1. Several fields, success
Status: Success
ENGINE_NUMBER 161FMJT5072510 0.986 (no message)
HPG_CONTROL_NO 0H1260349854 0.967 (no message)
SBR_NUMBER 22326118 0.989 (no message)
2. Partial success (a field fails its pattern)
Status: Success
HPG_CONTROL_NO OH1260349938 0.955 Field 'HPG_CONTROL_NO' does not match required pattern '^0H1\d{9}$'.
The value is still returned so you can review or fix it (here the OCR read 0 as the letter O).
3. Fail (nothing found)
Status: Success
ENGINE_NUMBER "" 0 Field value not found (only label detected).
Status: Failed <- when the call cannot run (bad template, page cannot be lined up, too few pages)
Errors: ["Template could not be loaded: <reason>"]
4. Whole document, no template
Status: Success Fields: []
DocumentText:
Page X Y Width Height Confidence Source Text
0 120 84 410 28 0.99 Ocr SPECIAL BANK RECEIPT
0 120 130 260 24 0.97 Ocr SBR No. 22326118
Limits
- Windows x64 only, English OCR only.
- OCR can confuse similar characters (
0/O,6/8). UsePatternto flag them and correct them in your code. - Text read straight from a digital PDF has no position (box 0/0/0/0).
License
This package: Apache-2.0. It bundles Ghostscript (AGPL or commercial license), which is fine for company-internal use.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Ghostscript.NativeAssets (>= 10.8.0)
- Ghostscript.NET (>= 1.3.6)
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.Logging (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- OpenCvSharp4.Windows (>= 4.11.0.20250507)
- Sdcb.PaddleInference.runtime.win64.mkl (>= 3.3.1.70)
- Sdcb.PaddleOCR (>= 3.3.1)
- Sdcb.PaddleOCR.Models.LocalV5 (>= 3.3.1)
- Serilog (>= 4.4.0)
- Serilog.Extensions.Logging (>= 8.0.0)
- Serilog.Sinks.Console (>= 6.1.1)
- SharpCompress (>= 0.48.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-preview.7 | 39 | 9/23/2026 |
| 0.1.0-preview.4 | 38 | 9/23/2026 |
| 0.1.0-preview.3 | 39 | 9/23/2026 |
| 0.1.0-preview.2 | 55 | 9/22/2026 |
| 0.1.0-preview.1 | 63 | 9/20/2026 |