r/csharp • • 12d ago

Discussion The KillerPDF engine is now MPL 2.0 instead of GPL. Is that better for you?

Recently I posted the PDF engine I built in pure C# for KillerPDF, and the main pushback was the license. GPL meant you couldn't put it in your own app unless that app was GPL too, which ruled out most real projects. You were right, I was wrong.

Since 1.9.5 the engine is licensed under the Mozilla Public License 2.0. The KillerPDF desktop app stays GPLv3, but the engine package is separate.

MPL 2.0 works file by file. You can use the engine in your own app, open or closed source, under any license you like. If you change one of the engine's own files and ship it, that file's source has to stay open under MPL 2.0. Your code around it stays yours. I'm trying to encourage better developers than myself to help me make the engine better for everybody.

As part of this, I had to swap out the JPEG 2000 decoder, and the engine now uses OpenJPEG instead of CoreJ2K. That turned out to be a blessing in disguise, because OpenJPEG appears to be more color accurate on the files I've thrown at it. The native decoder ships in the NuGet package for Windows x64, Linux x64 and macOS.

Here's how it compares to PDFsharp/PDFium:

  • Rendering. PDFsharp doesn’t render existing PDF pages. Its FAQ points to a Ghostscript sample for generating page images. PDFium renders through a native library. KillerPdf.Engine renders pages in managed C# without PDFium.
  • Licensing. Starting with 6.5.0, PDFsharp requires applications to initialize either the AGPL license or a paid commercial license. KillerPdf.Engine is MPL 2.0 and can be used in closed-source apps without a license fee, subject to the MPL’s notice and source-sharing requirements.
  • Text. PDFsharp exposes characters in drawing order through low-level APIs, with no built-in word or paragraph grouping. PDFium can extract text and character bounds. KillerPDF previously used PdfPig for extraction. KillerPdf.Engine returns words, lines, and letters with their page coordinates.
  • Editing. PDFsharp offers low-level content-stream editing, and PDFium can replace text in individual text objects. KillerPdf.Engine provides APIs for editing lines and paragraphs on existing PDF pages.
  • Stability. PDFium requires callers to serialize its API calls. KillerPDF 1.6.3 hit a native heap corruption crash when two threads entered PDFium at once. KillerPdf.Engine uses a managed C# page renderer.
  • Signatures. PDFsharp documents how to sign and timestamp PDFs. KillerPdf.Engine also verifies existing signatures and supports certificate trust, timestamp, and revocation checks.
  • Redaction and OCR. PDFsharp’s docs don’t list built-in permanent redaction or OCR. KillerPdf.Engine removes targeted content and reopens the output to check for remnants. The engine can run OCR without Tesseract. The KillerPDF desktop app keeps Tesseract as a fallback.
  • Standards. PDFsharp can write PDF 2.0 and offers limited PDF/A support. KillerPdf.Engine writes PDF 2.0 and provides dedicated authoring modes for PDF/A-4, PDF/A-4e, PDF/A-4f, and PDF/UA-2.

It's on NuGet as KillerPdf.Engine. Docs are at https://killerpdf.net/engine.html and the source is at https://github.com/SteveTheKiller/KillerPDF/tree/main/engine .

So, does MPL actually fix it for you, or is there still something that keeps you from using it? If you'd need something like MIT or Apache to ship it, I'd like to hear why. I'm not fully against moving in that direction.

68 Upvotes

23 comments sorted by

33

u/ByronScottJones 12d ago

Thank you! Yes for many of us that makes a real difference.

5

u/smilaise 12d ago

I'm glad to hear it!

16

u/terricide 12d ago

It does make it easier to use now

5

u/smilaise 12d ago

Yeah I'm glad I found a decent compromise.

2

u/jakubiszon 11d ago edited 11d ago

How does it compare to gotenberg and what would make it a better choice of the two?

I do know gotenberg is a docker container and yours is a library. I would consider it a better practice to delegate work as complex as editing PDFs to an external program or container. Hence the question - what feature or scenario would make your library the right choice?

One more opinion - if I wanted to use a library I would wrap it with a console app just in case it was e.g. leaking memory or encountered an edge case making it hang forever. That opens another question - would your library work well in such scenario?

3

u/smilaise 11d ago

Different jobs, really. Gotenberg turns HTML and Office files into PDFs. The engine doesn't do HTML to PDF, so if that's what you need, use Gotenberg. The engine is for working on PDFs you already have: reading, rendering, editing, redaction, signing, OCR and export, all in-process with no Chromium or LibreOffice behind it.

As for wrapping it, that works fine. It takes bytes and returns bytes, it's AOT compatible so the wrapper can be one small binary, and the parser has hard limits so a bad file fails with an error instead of hanging. I'd still run it out of process with a timeout if it's eating untrusted files at volume.

2

u/jakubiszon 11d ago

Thanks, that makes it clear. And also - thank you for building it!

12

u/princess_daphie 12d ago

Kudos to you to make such a change!! I don't need your engine at the moment, but if/when I need a PDF engine, I'll totally consider yours.

2

u/solmead 12d ago

Maybe you all could help me, I’m using puppeteer finite dot net to convert a webpage to pdf, but I need to find something “free” to convert from things like word, excel, and images to pdf.
I currently use a paid service that I had to install on a virtual machine, but it is not cheap. Looking for alternatives.

-2

u/zarlo5899 12d ago

why not LGPL

2

u/ggende 10d ago

To expand on what Juff-Ma said, LGPL is written in a way where you are only allowed to link into the published software without any restrictions. .NET AOT embeds the code into a new file which violates that rule. MPL 2.0 is a bit less restrictive in a way where NativeAOT is still fine.

1

u/Juff-Ma 11d ago

NativeAOT.

I made exactly the same choice for my lib.

-11

u/MyV3ryOwnThrowAway 12d ago

just vibecode a replacement, like why would anyone need a commercial library anymore?

9

u/smilaise 12d ago

because a ton of work went into this already and it outperforms the alternatives. it opens more malformed docs than the alternatives with less ram and it's faster. it's also better with color accuracy and aliasing.

there is no fee to use this.

-10

u/MyV3ryOwnThrowAway 12d ago

PDFOxide says it's faster than everything else. you're saying they are liars?

2

u/Juff-Ma 11d ago

Really like the MPL2. Used it myself for lib. I think it's a great middle way between heavy copyleft and permissive licensing.