Open source · Bibliothèque PDF .NET
Smaller PDFs, and proof that nothing changed.
Compressing a PDF in .NET often means a native tool, a copyleft or commercial license, or a rebuild of the document that quietly loses forms, tags or metadata. PdfNetStack does the job in pure C#, reads back the file it just wrote and compares it to the source. If anything differs, you get your original bytes back.

dotnet add package PdfNetStackdotnet tool install -g PdfNetStack.Tool- License
- MIT
- Runtime
- .NET 8+, .NET Standard 2.0
- Language
- C#
The problem
Most PDF compression in .NET shells out to a native tool, depends on a copyleft or commercial library, or rebuilds the document and quietly loses forms, tags or metadata.
For a service that handles files from outside, all three cause trouble: a native binary to ship per platform, a license to check, and no guarantee that the output says the same thing as the input.
We wanted a library that is permissively licensed all the way down, safe on files from strangers, and honest about what it changes.
What we did
The code is original and written from the published specifications: ISO 32000 for PDF, OpenType, Unicode, and the HTML and CSS standards. There is no native code and no external process, and it behaves the same on Windows, Linux and macOS.
Optimization is lossless by default: compressed object streams, unused resources dropped, streams recompressed, duplicate fonts and images merged. The verifier then walks the source and the output in lockstep. Dictionaries must have the same keys and values, and every stream must decode to identical bytes. A difference returns the original file.
Encrypted, signed and damaged files are returned byte for byte. Lossy image options must be turned on explicitly, and the proof then checks the bounds of each change.
Around that core: document creation and editing, forms, PDF/A, Factur-X, AES encryption, text and image extraction, HTML and CSS to PDF, OCR in a separate package, and PAdES signatures from B-B to B-LTA with validation of certificate chains and of the EU trusted lists you supply.
Where it stands
PdfNetStack is published on NuGet and GitHub under the MIT license. On .NET 8 and later the core package has no dependencies. On .NET Standard 2.0 it uses Microsoft's System.Memory.
We measure it on a public corpus of 77 openly licensed PDFs, 4,045 pages, listed by URL and SHA-256. The lossless profile rewrote 65 of them and saved 12.1%, from 196.6 MiB to 172.9 MiB. The other 12 are signed or encrypted and were left alone. No rewrite failed its proof. The Balanced preset, lossy but at full resolution, saves 23.4%, and the benchmark's lossy profile 32.1%.
CI runs the full test suite on .NET Framework 4.8, .NET 8 and .NET 10, on Windows, Linux and macOS. The corpus benchmark runs weekly and for every version, and its report is attached to the GitHub release.
We publish no user count. The saving depends on what produced the PDF: a file from a well tuned producer has little left to gain losslessly.
- C#
- .NET 8
- .NET 10
- .NET Standard 2.0
- Native AOT
- GitHub Actions
Modern C#, because optimization is mostly parsing, hashing and zlib, which .NET now does at close to native speed. No per-platform binary to ship, and Native AOT publishing with no warnings.
Frequently asked questions
- Is PdfNetStack a client project?
- No. It is an original library we maintain as open source. We cite it as engineering evidence, not as a client endorsement.
- Can we use it in a commercial product?
- Yes. The MIT license allows commercial use with no fee. CI blocks any runtime package whose license is not on a reviewed allowlist.
- Does optimization degrade the document?
- Not by default. The default mode is lossless and proven. Image quality only changes if you turn on a lossy option, and a quality gate can then drop a change that would hurt the image.
- Which runtimes are supported?
- .NET 8, 9, 10 and later, plus .NET Framework 4.6.2 to 4.8.1, Mono, Unity, Xamarin and .NET Core 2.0 or later through .NET Standard 2.0. The main libraries also publish with Native AOT on Linux x64 and ARM64.
- Can you integrate it into our system?
- Yes. We can build PDF processing into your .NET application. Describe what you need and we reply with a scope and a price.
PDF processing to build into your system?
Describe your documents, your volumes and what blocks you today, without confidential files. We reply with a scope and a price.
Describe my need- PDF library for .NET: verified compression, MIT licenseWhile helping a client get rid of a third-party PDF library, we wrote PdfNetStack from the specifications. How it checks every compression, and why we publish it under the MIT license.
- Cypress MCP server: let the AI agent run your E2E testsCoding agents write Cypress tests but cannot run them. What we built to close the loop, and what production taught us along the way.
- ParkAgenda · Operations SaaS for airport parkingMulti-channel bookings reduced to a single queue, then shuttles, staff scheduling, vehicle condition capture and on-site payment.
- AutoMotoMarket.be · Used vehicle marketplaceAutoScout and mobile.de stock ingestion, CSV and XML import, verified sellers, three languages, subscription tier for dealers.
- Pavimmo · CRM migration with zero business interruptionYears of client history cleaned, mapped and reconciled, with the source system in production from the first day to the last.
- cypress-mcp · open-source MCP server for CypressThe AI agent runs Cypress tests, reads failures and reruns without copy and paste. Apache 2.0, Windows, macOS and Linux.

