Member-only story
How to Create Pdf’s in C#
A guide to the best open-source Pdf library in .Net: QuestPdf.
Are you tired of converting HTML to Pdf? Are you at your wit's end trying to get your page numbers to change dynamically no matter the length of your table? Are you sick of your reports looking like a degenerate hamster knocked one out in his spare time?
Then look no further… QuestPdf is here to save the day — and the best thing is, it's Open Source.
Sorry AsposePdf. You’re out. Next!
First off, let’s give a big shoutout to the legend, the superstar, this specimen of a man, to the creator of QuestPdf, Marcin Ziąbek. This man has saved us literally thousands of pounds, and development hours, generating reports for our company. Not only that but we clocked it to be at least 50% faster than AsposePdf!
Please join us by buying this man a coffee, donating, or sponsoring his project here: https://github.com/QuestPDF/QuestPDF
What I want you to get from this is that you simply copy and paste the code below, then strip away from it what you don’t need. Basically, I give you an intact bike, and you throw away the tassles, bells, and playing cards in the spokes whilst leaving the frame intact!
How to get started!
First of all, QuestPdf already has fantastic documentation here but if you want to see some cutting-edge stuff, I’ve included an example statement, and the code behind it to really show you its power! This is actually close to some of the statements we send out to customers currently, obviously with a few tweaks here and there…
So, all you need to do is install the library via the nuget package manager specifically for QuestPdf & QuestPdf.Previewer (if in dotnet 6).
Without further ado, this is what we are building: