Love to code although it bugs me.

14 May 2021

Generating PDF in .NET Core using Libreoffice

Looking for Nuget extensions to generate PDF output, there’s a lot of offer, but you have to either convert from another format like HTML or hard-code each page, text block, and layout. Also, most extensions come in freemium versions.

An interesting option is used by the team at Smart In Media GmbH & Co. KG. To use their words:

I was surprised, just how difficult that endeavor is if you don’t want to pay huge amounts of money to commercial libraries. The cheapest start at U$300 and the most expensive was around U$5,000.

So they came up with the Report-From-DocX-HTML-To-PDF-Converter project. It’s also available as a NuGet package.

The idea behind it is to use FOSS all the way, implementing DOCX/HTML templates with placeholders, turned into PDF afterward using Libreoffice’s portable version. Everything you need to get started is on the project’s Github page.

I did a test drive project, it’s available on my personal Automate .NET Core project.