Pdfium.Net.SDK
5.1.3
dotnet add package Pdfium.Net.SDK --version 5.1.3
NuGet\Install-Package Pdfium.Net.SDK -Version 5.1.3
<PackageReference Include="Pdfium.Net.SDK" Version="5.1.3" />
<PackageVersion Include="Pdfium.Net.SDK" Version="5.1.3" />
<PackageReference Include="Pdfium.Net.SDK" />
paket add Pdfium.Net.SDK --version 5.1.3
#r "nuget: Pdfium.Net.SDK, 5.1.3"
#:package Pdfium.Net.SDK@5.1.3
#addin nuget:?package=Pdfium.Net.SDK&version=5.1.3
#tool nuget:?package=Pdfium.Net.SDK&version=5.1.3
PDFium.NET.SDK
PDFium.NET.SDK is a high-performance, cross-platform C# PDF library designed for modern .NET applications. Fully optimized for Native AOT compilation, it delivers blazing-fast startup times and minimal RAM overhead, making it the perfect solution for cloud microservices, AWS Lambda, and ultra-lightweight Docker containers requiring instant cold starts.
With a single package, you get native execution and zero-configuration cross-platform support across Windows, Linux (including Alpine musl-libc), macOS (Intel & Apple Silicon M1-M4), Android, and iOS with full ARM layouts support.
The future of technology, with total legacy respect: While empowering cloud modernization under Native AOT (.NET 8/9/10), it maintains absolute backward compatibility down to .NET Framework 2.0 to protect your legacy infrastructure investments.
Key Features of Version 5.x
- High-Performance Rendering: Complete support for all PDF rendering capabilities and complex document layouts.
- Document Manipulation: Create PDFs from scratch, merge, split, and extract pages.
- Text & Image Extraction: Fast text search, selection, and structured data extraction.
- UI Components: Built-in PDF Viewer controls for WinForms and WPF applications.
- PDF/A, ZUGFeRD, and Factur-X Ready: Out-of-the-box readiness for long-term archiving standards and modern electronic invoicing formats (ZUGFeRD / Factur-X), combining PDF visual data with structured XML metadata.
- Full Native AOT Compatibility: The internal architecture has been fully refactored to support AOT. This ensures seamless operation when compiling with Ahead-of-Time (AOT) deployment, entirely eliminating runtime JIT compilation issues. Perfect for AWS Lambda, cloud microservices, and lightweight Docker containers requiring instant cold starts.
Satellite Packages
The NuGet package manager automatically identifies your application's target architecture and restores the appropriate dependency:
- Pdfium.Net.SDK.runtime.win: Native binaries for Windows (x86, x64) optimized for desktop applications (WPF, WinForms, WinUI).
- Pdfium.Net.SDK.runtime.linux: Native binaries for Linux servers and standard containers based on x64 and arm64 architectures (Ubuntu, Debian, CentOS).
- Pdfium.Net.SDK.runtime.linux-musl: Specialized build targeting ultra-lightweight Alpine Linux containers (musl-libc).
- Pdfium.Net.SDK.runtime.osx: Support for macOS environments (compatible with both Intel and Apple Silicon M1/M2/M3/M4 chips).
- Pdfium.Net.SDK.runtime.android: Mobile native libraries compiling for armeabi-v7a, arm64-v8a, and x86_64 architectures.
Note: You only need to install the main Pdfium.Net.SDK package. Satellite runtime packages are automatically restored as transitive dependencies based on your active deployment target.
Quick Start
Before calling any method of the SDK, you must initialize the library once during your application startup.
using Patagames.Pdf.Net;
// Initialize the C# PDF Library
PdfCommon.Initialize();
1. Render PDF Page to an Image
Easily convert any PDF page into a standard image object (e.g., for generation of thumbnails or visual rendering):
using Patagames.Pdf.Net;
using System.Drawing;
using System.Drawing.Imaging;
// Initialize SDK first
PdfCommon.Initialize();
using (var doc = PdfDocument.Load("sample.pdf"))
{
// Access the first page (0-indexed)
using (var page = doc.Pages[0])
{
// Render page to a System.Drawing.Bitmap at 300 DPI
int width = (int)(page.Width / 72.0 * 300);
int height = (int)(page.Height / 72.0 * 300);
using (var bitmap = new PdfBitmap(width, height, true))
{
bitmap.FillRect(0, 0, width, height, FS_COLOR.White);
page.Render(bitmap, 0, 0, width, height, PageRotate.Normal, RenderFlags.FPDF_LCD_TEXT);
bitmap.Image.Save($"image.png", ImageFormat.Png);
}
}
}
2. Extract Text from PDF Documents
Extract clean, structured text and process layouts from any PDF file in just a few lines of code:
using Patagames.Pdf.Net;
using System;
PdfCommon.Initialize();
using (var doc = PdfDocument.Load("invoice.pdf"))
{
foreach (var page in doc.Pages)
{
// Extract all plain text from the current page
int totalCharCount = page.Text.CountChars;
//Extract text from page to the string
string text = page.Text.GetText(0, totalCharCount);
Console.WriteLine(text);
}
}
3. Merge or Import Pages Between PDFs
Select specific pages from existing files and dynamically merge them into a single PDF document:
using Patagames.Pdf.Net;
PdfCommon.Initialize();
using (var sourceDoc = PdfDocument.Load("source.pdf"))
using (var targetDoc = PdfDocument.CreateNew()) // Create a blank PDF from scratch
{
// Import the first 3 pages from the source document into the new target document
// Parameters: source document, page indexes string (e.g., "0-2"), target insertion index
targetDoc.Pages.ImportPages(sourceDoc, "0-2", 0);
targetDoc.Save("merged_output.pdf", SaveFlags.NoIncremental);
}
.NET Framework vs .NET Modern (Core) Compatibility Guardrails
To prevent compilation errors, ensure you follow the correct API patterns based on your target framework and operating system:
| Feature / Platform | Modern .NET (8 / 9 / 10) | Legacy .NET Framework (2.0 - 4.8) |
|---|---|---|
| Compilation Mode | Supports Native AOT & JIT | JIT Only |
| OS Support | Windows, Linux (Glibc/Musl), macOS, Mobile | Windows Only |
| Image Handling | Use pure PdfBitmap for cross-platform |
Supports standard GDI/Windows Graphics |
Windows GDI API (.Image) |
Supported on Windows only via included Patagames.Pdf.Gdi.dll extension |
Included natively in the core lifecycle |
| Deployment | Runtimes are restored transitively | Requires native ptgpdfcore.dll in the app bin folder |
Important for Developers (API Architecture Rules):
- Windows GDI Dependency (
PdfBitmap.Image): The propertyPdfBitmap.Imagerelies on Windows-specific GDI features. In modern .NET cross-platform environments, this GDI-dependent API is located in the companion assemblyPatagames.Pdf.Gdi.dll, which is already included in the main package. - Cross-Platform / Linux Containers: If you are deploying to Linux Docker, Alpine, or AWS Lambda, do not use
PdfBitmap.Imageor references fromPatagames.Pdf.Gdi.dll. These are Windows-only extensions and will fail on non-Windows platforms. Instead, use pure, cross-platformPdfBitmapmethods for saving images or pixel manipulation. - Using GDI on Windows: If you are building a modern .NET application specifically for Windows (e.g., WPF, WinForms) and need GDI features like
System.Drawing.Image, you can safely use thePdfBitmap.Imageproperty out of the box, as the required GDI extension assembly is pre-bundled. - Targeting Native AOT: The core library architecture is fully pre-compiled and optimized. Do not use runtime reflection when working with the SDK to maintain full Ahead-of-Time deployment compatibility.
Documentation
For complete API references, initialization guides, and step-by-step tutorials, please visit our official documentation:
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net5.0-windows7.0 is compatible. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net6.0-windows7.0 is compatible. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net7.0-windows7.0 is compatible. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net8.0-windows7.0 is compatible. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net9.0-windows7.0 is compatible. 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-windows7.0 is compatible. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net20 is compatible. net35 is compatible. net40 is compatible. net403 was computed. net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Universal Windows Platform | uap was computed. uap10.0 is compatible. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 2.0
- icudt.runtime.win (>= 1.0.1)
- PtgPdfCore.runtime.win (>= 5.0.6)
-
.NETFramework 3.5
- icudt.runtime.win (>= 1.0.1)
- PtgPdfCore.runtime.win (>= 5.0.6)
-
.NETFramework 4.0
- icudt.runtime.win (>= 1.0.1)
- PtgPdfCore.runtime.win (>= 5.0.6)
-
.NETFramework 4.5
- icudt.runtime.win (>= 1.0.1)
- PtgPdfCore.runtime.win (>= 5.0.6)
-
.NETFramework 4.8
- icudt.runtime.win (>= 1.0.1)
- PtgPdfCore.runtime.win (>= 5.0.6)
-
.NETStandard 2.0
- icudt.runtime.win (>= 1.0.1)
- PtgPdfCore.runtime.linux (>= 5.0.6)
- PtgPdfCore.runtime.linux-musl (>= 5.0.6)
- PtgPdfCore.runtime.osx (>= 5.0.6)
- PtgPdfCore.runtime.win (>= 5.0.6)
-
net10.0
- icudt.runtime.win (>= 1.0.1)
- PtgPdfCore.runtime.linux (>= 5.0.6)
- PtgPdfCore.runtime.linux-musl (>= 5.0.6)
- PtgPdfCore.runtime.osx (>= 5.0.6)
- PtgPdfCore.runtime.win (>= 5.0.6)
-
net10.0-android21.0
- PtgPdfCore.runtime.android (>= 5.0.6)
-
net10.0-macos10.13
- PtgPdfCore.runtime.osx (>= 5.0.6)
-
net10.0-windows7.0
- icudt.runtime.win (>= 1.0.1)
- PtgPdfCore.runtime.win (>= 5.0.6)
-
net5.0
- icudt.runtime.win (>= 1.0.1)
- PtgPdfCore.runtime.linux (>= 5.0.6)
- PtgPdfCore.runtime.linux-musl (>= 5.0.6)
- PtgPdfCore.runtime.osx (>= 5.0.6)
- PtgPdfCore.runtime.win (>= 5.0.6)
-
net5.0-android21.0
- PtgPdfCore.runtime.android (>= 5.0.6)
-
net5.0-macos10.13
- PtgPdfCore.runtime.osx (>= 5.0.6)
-
net5.0-windows7.0
- icudt.runtime.win (>= 1.0.1)
- PtgPdfCore.runtime.win (>= 5.0.6)
-
net6.0
- icudt.runtime.win (>= 1.0.1)
- PtgPdfCore.runtime.linux (>= 5.0.6)
- PtgPdfCore.runtime.linux-musl (>= 5.0.6)
- PtgPdfCore.runtime.osx (>= 5.0.6)
- PtgPdfCore.runtime.win (>= 5.0.6)
-
net6.0-android21.0
- PtgPdfCore.runtime.android (>= 5.0.6)
-
net6.0-macos10.13
- PtgPdfCore.runtime.osx (>= 5.0.6)
-
net6.0-windows7.0
- icudt.runtime.win (>= 1.0.1)
- PtgPdfCore.runtime.win (>= 5.0.6)
-
net7.0
- icudt.runtime.win (>= 1.0.1)
- PtgPdfCore.runtime.linux (>= 5.0.6)
- PtgPdfCore.runtime.linux-musl (>= 5.0.6)
- PtgPdfCore.runtime.osx (>= 5.0.6)
- PtgPdfCore.runtime.win (>= 5.0.6)
-
net7.0-android21.0
- PtgPdfCore.runtime.android (>= 5.0.6)
-
net7.0-macos10.13
- PtgPdfCore.runtime.osx (>= 5.0.6)
-
net7.0-windows7.0
- icudt.runtime.win (>= 1.0.1)
- PtgPdfCore.runtime.win (>= 5.0.6)
-
net8.0
- icudt.runtime.win (>= 1.0.1)
- PtgPdfCore.runtime.linux (>= 5.0.6)
- PtgPdfCore.runtime.linux-musl (>= 5.0.6)
- PtgPdfCore.runtime.osx (>= 5.0.6)
- PtgPdfCore.runtime.win (>= 5.0.6)
-
net8.0-android21.0
- PtgPdfCore.runtime.android (>= 5.0.6)
-
net8.0-macos10.13
- PtgPdfCore.runtime.osx (>= 5.0.6)
-
net8.0-windows7.0
- icudt.runtime.win (>= 1.0.1)
- PtgPdfCore.runtime.win (>= 5.0.6)
-
net9.0
- icudt.runtime.win (>= 1.0.1)
- PtgPdfCore.runtime.linux (>= 5.0.6)
- PtgPdfCore.runtime.linux-musl (>= 5.0.6)
- PtgPdfCore.runtime.osx (>= 5.0.6)
- PtgPdfCore.runtime.win (>= 5.0.6)
-
net9.0-android21.0
- PtgPdfCore.runtime.android (>= 5.0.6)
-
net9.0-macos10.13
- PtgPdfCore.runtime.osx (>= 5.0.6)
-
net9.0-windows7.0
- icudt.runtime.win (>= 1.0.1)
- PtgPdfCore.runtime.win (>= 5.0.6)
-
UAP 10.0
- icudt.runtime.win (>= 1.0.1)
- PtgPdfCore.runtime.win (>= 5.0.6)
- win2d.uwp (>= 1.27.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Pdfium.Net.SDK:
| Package | Downloads |
|---|---|
|
SuperMemoAssistant.Plugins.PDF.WPF
. |
|
|
Luval.Pdf2Image.Activities.Implementation
Provides a way to convert PDF file into images |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Pdfium.Net.SDK:
| Repository | Stars |
|---|---|
|
axzxs2001/Asp.NetCoreExperiment
原来所有项目都移动到**OleVersion**目录下进行保留。新的案例装以.net 5.0为主,一部分对以前案例进行升级,一部分将以前的工作经验总结出来,以供大家参考!
|