PDF Libs for C#
May 19, 2020

PDF Libs for C#

A quick and admittedly superficial comparison of available PDF libraries for C#/.Net

In one of our WPF ClickOnce projects we need to be able to generate a PDF report from an existing template (which is itself a PDF). The requirements are not complex:

  • C# (.Net framework 4.8)
  • Open an existing PDF document that contains fields and use it as a template (each field has a name, and during the pdf file generation the fields should be replaced with formatted text)
  • Add basic formatted text (bold/italic etc)
  • "Flow" text between areas
  • Possibility to digitally sign the document

Not very fancy requirements but a good opportunity to compare available libraries that may be up to the task.

We initially chose ABCpdf because it has good documentation and seemed affordable. Unfortunately only after developing the feature did we realise that their license is per computer, not per software project. Our app is a WPF app deployed via ClickOnce, which can be run on any client machine. Everything worked fine on our dev box until we wanted to deploy it. Then we realized that the "SuperGoo" company expects you to install ABCPdf on each computer that will generate pdf-s. We got around this by including the necessary DLL-s in our app only to then find out that we should buy $4,000+ of licenses to purchase an enterprise license to run it on a few computers. Well, I guess they don't want to bother with "small" clients/projects like us! A shame, because we would have had no problem shelling out $400 but 4K no way.

We then looked into Aspose.PDF. This looked like a good solution but costs $1k. They have live chat and they offered to give a discount if we write a blog post about their product - we may consider doing this at some point in time. We played around with their product. They seem to have rolled two PDF libraries into one, and because of this certain things should be done with one API while others should be done with another API, and this makes things somewhat complicated. But overall it seems like a pretty good library and we were going to use it until we realized that Syncfusion's "Essential PDF" solution is available for free for small companies. So this is what we went with.

Unfortunately, it seems that Syncfusion's "Essential PDF" is a repackaged version of "Spire PDF". Perhaps they bought the rights, I don't know. In any case it turned out that their PDF library is usable but very, very poorly designed. Things are much more difficult to implement than with ABCpdf or Aspose.PDF. For example, flowing plain text from one area to another is not well documented and somewhat difficult to implement with plain text, and pretty much impossible to do with the PdfHTMLTextElement (which can draw rich "HTML-styled" text). Speaking of the PdfHTMLTextElement, if you get stuck trying to break your text into separate lines, you have to type "<br/>" exactly,  "<br>" throws an error while other variations like "<br />" or "<br></br>" simply don't work (and the only place where you can find this out is in a thread on their support forum). Occasionally a call would simply hang forever (for example if pagination was set to on with a rich html text field, calling the .Draw() method would just hang forever).

Another problem we ran into was editing an existing PDF. This really isn't possible with Syncfusion - you can't just edit a text element for example. And if you want to add a new text element to a page you have to use a separate method when working with a PDF that was opened (graphics.DrawString) as opposed to a PDF you create in code (PdfTextElement.Draw). The two methods are quite similar but the first is lacking in several respects, for example you can't draw text into a predefined "box". So then you try to import pages from an existing document onto a newly created document, but that doesn't work well, forms are messed up and other issues arise.

The documentation is also quite raw and lacking in many places. It has some example code but the result (what it actually looks like in a generated pdf) is never included, so you're left wondering what certain functions actually do. Many methods/functions/parameters have no documentation at all. For example, what do the "PdfLayoutType" options "OnePage" and "Paginate" actually do? The documentation offers a one-sentence explanation. Or how do these options interact with PdfLayoutBreakType, which has options "FitColumnsToPage" / "FitElement" / "FitPage"? We couldn't figure it out.

Still, the documentation is better than what is available for PdfSharp. But PdfSharp is free while Syncfusion's product starts at around a grand.

And iText7? Well, they don't even make their pricing public, and you know that if you need to get a custom quote for a product then it ain't gonna be cheap!

Disclaimer: this is our company blog mostly for our own benefit and we make no money off of it, and you won't find any affiliate links here.

A good starting point: https://www.reddit.com/r/dotnet/comments/8a83jh/what_is_the_current_best_way_of_creating_pdf/

So that's our story so far. Here's a list of PDF libraries we found and our impressions:

Listed in order of popularity (avg daily downloads on Nuget)...\

dl/d = avg-downloads-per-dayccccccjgkgdtenrvfrdjjtlftijnknbuukjkcckulngg

PdfSharp   ◆   1,524 dl/d   ◆   👎

PdfSharp 1.50.5147
PDFsharp is the Open Source .NET library that easily creates and processes PDF documents on the fly from any .NET language. The same drawing routines can be used to create PDF documents, draw on the screen, or send output to any printer. This is the PDFsharp PDF Core package. See Project Informatio…

By far the most popular package in large part probably because it's open-source and free.

However, there doesn't seem to be any straightforward support for signing pdf documents, and the existing documentation is a little convoluted and lacking.

iText7   ◆   778 dl/d   ◆   $?   ◆   👎

itext7 7.1.11
iText 7 represents the next level of SDKs for developers that want to take advantage of the benefits PDF can bring. Equipped with a better document engine, high- and low-level programming capabilities and the ability to create, edit and enhance PDF documents, iText 7 can be a boon to nearly every wo…

Originally started as "iTextSharp", an open-source and free port of a java library for editing pdf-s, it was rebranded "iText" and rewritten and fully commercialized. The original iTextSharp lib has been deprecated.

Currently there is an "open-source" version licensed under AGPL - but that means your own app has to be open-source to use it. No published pricing available for the commercial edition, you have to fill in a contact for to get a quote and give a valid phone number. Not a fan of that, so as awesome as it might be, we're skipping it for now. Also way too much legal banter on the website and the documentation is difficult to navigate.

API docs

Aspose.PDF for .NET   ◆   654 dl/d   ◆   $999+

Aspose.Pdf 20.5.0
Aspose.PDF for .NET is a PDF document creation and manipulation component that enables your .NET applications to read, write and manipulate existing PDF documents without using Adobe Acrobat. It also allows you to create forms and manage form fields embedded in a PDF document. This component is writ…

$999 per project which is out of our budget range although you can get a bit of a discount if you write a blog entry or are willing to publicize their product in some other way. Documentation seems solid and it has a lot of features.

Syncfusion Essential PDF   ◆   538 dl/d   ◆   $995+

Syncfusion.Pdf.Net.Core 18.1.0.53
Syncfusion Essential PDF is a .NET standard PDF library used to create, read, and edit PDF files in any .NET Core applications. Key features: • Create, edit, fill, and flatten the AcroForm form fields. • Merge, split, rearrange, and remove pages. • Create accessible PDF (PDF/UA) from scratch. • Wat…

Again, $995 per project is just too expensive for our needs, however small companies can get a license for free so this is what we're using at the moment.

Also, lots of reports of large memory usage and crashes...

IronPDF   ◆   303 dl/d   ◆   $399+   ◆   👎

IronPdf 2020.3.2
IronPDF allows developers to create, edit and extract PDF content in .NET Standard, Core and Framework Projects. The Iron PDF library takes the frustration out of generating PDF documents by not relying on proprietary APIs. “Html-To-Pdf” renders pixel-perfect PDFs from open standard document types:…

$399/project which is acceptable pricing for us. Lots of great examples and the documentation is easy to navigate. Easy to sign pdf-s as well. Unfortunately, it's a more limited library than the previous ones because it uses an embedded Chromium web browser to render PDF from html. Their own FAQ explains this well:

When using iTextSharp PDF library, each piece of pdf text, graphic, table or line is “plotted” or drawn onto a PDF. This model allows precision but many developers complain that it is time consuming to generate PDFs - and that it is very time hard to closely match existing design styles or web assets.
The iTextSharp DLL has advanced PDF manipulation APIs that are powerful, and follow the PDF standard closely.
When viewing iTextSharp documentation, we see is a port of a Java Library called "iText". In keeping, the methodology and programatic interface has a distinct Java flavor.
In contrast, Iron PDF uses an embedded, full Chromium based web browser renderer to convert html to pdf (including C# code examples) allowing developers to generate PDFs from HTML, images and CSS.

From: "Is IronPDF an iTextSharp Alternative?"

ABCpdf   ◆   256 dl/d   ◆   $329 - $5,000+   ◆   👍

ABCpdf 11.3.8
PDF creation and manipulation using ABCpdf - a powerful and flexible PDF component for .NET. ABCpdf is a .NET component for PDF manipulation. As such, you’ll find it documented for C# and VB.NET, with numerous PDF code examples and freely adaptable projects, all designed to help you get up to speed…
ABCpdf gets up close and personal! Because it doesn’t use any print drivers and goes Direct to PDF™ it’s incredibly fast. ABCpdf incorporates virtually every feature you're ever likely to need in a PDF library.

They have a great page explaining digital signatures. The library also seems to have a lot of features. Their documentation is also very easy to understand and navigate. Their licensing sucks though and is not at all appropriate for ClickOnce apps (they want you to buy a license for each client computer that might use it).

GemBox.Document for .NET   ◆   210 dl/d   ◆   $240+   ◆   👎

GemBox.Document 31.0.1175
GemBox.Document is a .NET component that enables developers to read, write, convert and print document files (DOCX, DOC, PDF, HTML, XPS, RTF, TXT) from .NET applications in a simple and efficient way.

This seems to be a more limited library for now. For example, "GemBox.Pdf supports filling in a PDF interactive form. Currently, only filling in of toggle button fields (PdfCheckBoxField and PdfRadioButtonField) is supported."

Spire.PDF   ◆   166 dl/d   ◆   $599+

Spire.PDF 6.5.9
Spire.PDF for .NET is a versatile PDF library that enables software developers to generate, edit, read and manipulate PDF files within their own .NET applications. As a standalone PDF component, Spire.PDF for .NET provides users an incredible wealth of features without installing Adobe Acrobat. This…

Seems a bit expensive, so that's as far as we got. Also, it seems like their product is the same under the hood as what Syncfusion gives away for free for small companies. The documentation is the same word-for-word as the Syncfusion documentation...we suspect Syncfusion bought Spire.PDF or at least resale rights to it?

Please read the intro for an overview of our experiences with the Syncfusion product.

Apitron.PDF.Kit  ◆   78 dl/d   ◆   $1,300+

Apitron.PDF.Kit 2.0.29
It is 100% managed code and doesn’t require special manipulations to run with any .NET framework version starting from 2.0. PDF standard versions supported are: ALL versions. Files can be normal, linearized, password-protected, signed, incrementally updated. - We support many possible PDF conten…
Apitron PDF Kit is a .NET component that allows you to do whatever you want with PDF files. Add text, images, drawings, sign documents and much more.
You can also edit existing content using its friendly and easy to use API. It’s 100% managed code and doesn't require special manipulations to run with any .NET framework version starting from 2.0..

Sounds good but way too expensive!

Some others we didn't spend so much time with...

Essential Objects EO.Pdf  ◆   162 dl/d   ◆   $799+

EO.Pdf 20.1.45
EO.Pdf for .NET is a set of .NET components for you to easily create, read or modify PDF file in your Microsoft.NET application (both ASP.NET Web application and traditional Windows application). It also includes a powerful HTML to PDF converter that can handle almost everything a Web browser can ha…

Select.Pdf  ◆   126 dl/d   ◆   $499+

Select.Pdf 20.1.0
SelectPdf can be used as a general purpose PDF library in any .NET application. It offers the possibility to create or modify existing documents, add new elements (like text, html, images, shapes), change pdf document security settings, merge or split existing documents and many more. Select.Pdf al…

DynamicPDF  ◆   61 dl/d   ◆   $899+

DynamicPDF 8.0.0
ceTe DynamicPDF 8.0.0 for .NET binaries. Requires a license for actual usage (http://www.dynamicpdf.com/Products/DynamicPDFForNET/Merger/Download.csp)

ComponentPro PDF Document  ◆   7 dl/d   ◆   $599

ComponentPro.Pdf 7.2.234
Ultimate PDF (http://www.componentpro.com/products/pdf) lets you add the capability of creating, modifying and converting PDF documents to your .NET applications in just a few lines of code. It also supports converting HTML to PDF with latest supports for HTML5 and CSS3. It works with Wpf, WinForms,…

PDFLib

(couldn't find a nuget package)

Adobe® PDF Library™ SDK by Datalogics

There are also a lot of html-to-pdf-converter libs, such as:

EvoPDF  ◆   200 dl/d   ◆   $450+

EvoPDF 8.0.0
EVO HTML to PDF Converter is a .NET library that can be easily integrated in any type of .NET application to convert web pages, HTML strings and streams to PDF or to image. The converter has support for HTML5, CSS3, SVG, Canvas, Web Fonts and JavaScript. Does not require installation or any third pa…
EVO HTML to PDF Converter is a .NET library that can be easily integrated in any type of .NET application to convert web pages, HTML strings and streams to PDF or to image.

Other references

PDF Libs for C#
Share this