u/jhaygood86

▲ 53 r/dotnet

PeachPDF -- Fully Managed HTML to PDF Conversion

PeachPDF is a pure .NET HTML -> PDF rendering library, with a recently released 0.9 release. What does pure .NET mean? This means no Chromium wrappers, no out-of-process tools, no managed libraries, and no limitations of where it will run.

tl;dr -- if you need HTML to PDF conversion, check us out at https://peachpdf.net/

If .NET 8 runs somewhere, so will this. And as a side benefit, all of the performance improvements made in .NET benefit this library immediately.

In the last year, we've made great strides with standards and features support, such as page-level header and footers use CSS Paged Media and CSS Generated Content support.

The list of what's NOT supported is probably the most relevant list:

  • SVG -- we plan on implementing it though
  • CSS Flex (coming in 0.9.1)
  • CSS Grid (coming in 0.9.2)
  • CSS Transforms (coming in 0.9.1 except for perspective)
  • CSSTransitions & Animations (its a PDF, no plans on supporting it)
  • CSS Filters & Effects
  • CSS Variables (coming in 0.9.1)
  • CSS calc() expressions (coming in 0.9.1)
  • CSS Psuedo-classes and psuedo-elements still only have partial support
  • Editable Forms
  • Tagged PDFs
  • PDF/A

The 3 main competitors to this are PuppeteerSharp, IronPDF, and PrinceXML. All have their drawbacks, mostly in terms of having to ship native code for all of them (Chromium for the first 2, Prince's native executive for PrinceXML)

PuppeteerSharp and IronPDF are pixel perfect, but... your shipping a huge browser engine. PrinceXML is a lot closer to how PeachPDF works, but its still a separate native executable.

If you've ever tried running these in Azure Functions, Docker, AWS Lambda, or inside Android or iOS, you know how much a PITA it is (if it's even possible). PeachPDF? It just works in all of these places, because its 100% C#

And performance? It's essentially instant for most normal-sized documents using pretty minimal amounts of memory. I haven't formally benchmarked it yet (I will at some point soon), but the peak memory usage is going to be early in the rendering pipeline while the CSS tree is applied to the DOM tree parsed from HTML. Layout is one of the most significant CPU-intensive portions, but its essentially just calculating X, Y, Width, and Height for every DOM element, so its not excessively expensive.

The best part? This is all 100% free and open source at https://github.com/jhaygood86/PeachPDF

reddit.com
u/jhaygood86 — 19 hours ago