Unpdf 0.10.0

dotnet add package Unpdf --version 0.10.0
                    
NuGet\Install-Package Unpdf -Version 0.10.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Unpdf" Version="0.10.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Unpdf" Version="0.10.0" />
                    
Directory.Packages.props
<PackageReference Include="Unpdf" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Unpdf --version 0.10.0
                    
#r "nuget: Unpdf, 0.10.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Unpdf@0.10.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Unpdf&version=0.10.0
                    
Install as a Cake Addin
#tool nuget:?package=Unpdf&version=0.10.0
                    
Install as a Cake Tool

Unpdf

.NET bindings for unpdf - High-performance PDF content extraction to Markdown, text, and JSON.

Installation

dotnet add package Unpdf

Quick Start

The API is handle-based: parse once into an UnpdfDocument, query it, then dispose it.

using Unpdf;

using var doc = UnpdfDocument.ParseFile("document.pdf");

// Markdown
Console.WriteLine(doc.ToMarkdown());

// Plain text
Console.WriteLine(doc.ToText());

// JSON
Console.WriteLine(doc.ToJson(compact: false));

// Metadata
Console.WriteLine($"Title: {doc.Title}");
Console.WriteLine($"Author: {doc.Author}");
Console.WriteLine($"Pages: {doc.SectionCount}");

// Native library version
Console.WriteLine(UnpdfDocument.Version);

Parse from memory instead of a path with UnpdfDocument.ParseBytes(byte[]).

Advanced Usage

Markdown options

using var doc = UnpdfDocument.ParseFile("document.pdf");

var markdown = doc.ToMarkdown(new MarkdownOptions
{
    IncludeFrontmatter = true,
    EscapeSpecialChars = true,
    ParagraphSpacing = true,
});

Per-page extraction

using var doc = UnpdfDocument.ParseFile("document.pdf");

for (int page = 1; page <= doc.SectionCount; page++)
{
    Console.WriteLine(doc.PageToText(page));
}

Detecting scanned (image-only) PDFs

Empty output can mean a scanned document, a genuinely blank page, or a parse failure. The introspection surface tells them apart:

using var doc = UnpdfDocument.ParseFile("scan.pdf");

// Document level
if (doc.GetExtractionQuality().IsScanPdf)
    Console.WriteLine("Scanned document - OCR required");

// Page level (works for mixed documents too)
var stats = doc.GetPageStats(1);
if (stats.TextOpCount == 0 && stats.ImageOpCount > 0)
    Console.WriteLine("Page 1 is image-only (scanned)");
else if (stats.TextOpCount == 0)
    Console.WriteLine("Page 1 is genuinely blank");

Note: a searchable scan (page image plus an invisible OCR text layer) reports TextOpCount > 0 — combine the check with OcrTextSuppressed, which flags pages whose unreadable OCR layer was dropped.

Handling failures

UnpdfException.Kind says why a call failed, so you can branch on the reason instead of matching on Message:

try
{
    using var doc = UnpdfDocument.ParseFile("document.pdf");
    Console.WriteLine(doc.ToMarkdown());
}
catch (UnpdfException e) when (e.Kind == UnpdfErrorKind.Encrypted)
{
    Console.WriteLine("Password required");
}
catch (UnpdfException e)
{
    Console.WriteLine($"Extraction failed ({e.Kind}): {e.Message}");
}

UnpdfErrorKind values are part of the native ABI: new reasons take new numbers and existing ones are never renumbered, so treat an unrecognised value as a generic failure. A failure raised by the managed wrapper rather than the native library reports UnpdfErrorKind.Other.

Embedded resources

Resource extraction is off by default in this binding's parse path (it bounds peak memory on large PDFs), so ResourceCount is 0 and GetResourceIds() is empty for documents parsed through ParseFile / ParseBytes. Use GetPageStats to detect image-only pages rather than ResourceCount.

API Reference

UnpdfDocument

Member Description
static UnpdfDocument ParseFile(string path) Parse a PDF from disk.
static UnpdfDocument ParseBytes(byte[] data) Parse a PDF from memory.
static string Version Native library version.
string ToMarkdown(MarkdownOptions? options = null) Render the whole document as Markdown.
string ToText() Render the whole document as plain text.
string ToJson(bool compact = false) Render the whole document as JSON.
string PlainText() Text without the render pipeline — faster, simpler output.
string PageToMarkdown(int pageNumber, MarkdownOptions? options = null) Render one page (1-indexed).
string PageToText(int pageNumber) Text of one page (1-indexed).
string? Title / string? Author Document metadata, or null when unset.
int SectionCount Number of pages.
int ResourceCount Size of the extracted-resource inventory — see above.
ExtractionQuality GetExtractionQuality() Document-level extraction diagnostics.
PageStats GetPageStats(int pageNumber) Per-page content-stream operator counts.
string[] GetResourceIds() Ids in the resource inventory.
JsonDocument? GetResourceInfo(string resourceId) Metadata for one resource.
byte[]? GetResourceData(string resourceId) Raw bytes of one resource.
void Dispose() Release the native handle.

MarkdownOptions

Property Type Default Description
IncludeFrontmatter bool false Emit YAML frontmatter with document metadata
EscapeSpecialChars bool false Escape Markdown special characters
ParagraphSpacing bool false Add extra spacing between paragraphs

ExtractionQuality

CharCount, WordCount, ReplacementCharCount, Encrypted, IsScanPdf, SuppressedOcrPages.

PageStats

Page, TextOpCount, ImageOpCount, OcrTextSuppressed.

UnpdfException

Message plus Kind (UnpdfErrorKind) — see "Handling failures".

License

MIT License

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Unpdf:

Package Downloads
FileFlux

Complete document processing SDK optimized for RAG systems. Transform PDF, DOCX, Excel, PowerPoint, Markdown and other formats into high-quality chunks with intelligent semantic boundary detection. Includes advanced chunking strategies, metadata extraction, and performance optimization.

FileFlux.Core

Pure document extraction SDK for RAG systems. Zero AI dependencies. Extract text from PDF, DOCX, Excel, PowerPoint, Markdown, HTML, and text files. Provides IDocumentReader interface and implementations. Use FileFlux.Core for extraction-only scenarios. For AI-enhanced extraction (image OCR, captioning), use the FileFlux package.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.10.0 0 7/28/2026
0.9.0 88 7/22/2026
0.8.0 89 7/21/2026
0.7.1 111 7/5/2026
0.7.0 567 5/31/2026
0.6.4 437 5/20/2026
0.6.3 121 5/12/2026
0.6.2 120 5/9/2026
0.6.1 124 5/9/2026
0.6.0 118 5/9/2026
0.5.0 123 5/9/2026
0.4.6 121 5/1/2026
0.4.5 136 4/15/2026
0.4.4 127 4/15/2026
0.4.3 120 4/14/2026
0.4.2 116 4/14/2026
0.4.1 134 4/14/2026
0.4.0 121 4/14/2026
0.2.4 3,269 3/10/2026
0.2.3 135 3/3/2026
Loading failed