86

Is there a pdf library attached/that can be attached to .NET 3.5 that allows creation of pdf files at runtime i.e opening a new pdf file, writing to it line by line, embedding images, etc and closing the pdf file all in C# code?

What I want is a set of tools and specifications which allow me to implement a customised pdf writer in C# without using Reporting Services' pdf output option.

Lonzo
  • 2,758
  • 4
  • 22
  • 27

13 Answers13

121

iTextSharp is no longer licensed under the MIT/LGPL license. Versions greater than 4.1.6 are licensed under the Affero GPL, meaning you can't even use it in a SaaS (Software as a Service) scenario without licensing your code under the GPL, or a GPL-compatible license.

Other opensource PDF implementations in native .NET include

There's also a couple of Java PDF libraries (like PDFBox) you can convert to .NET using IKVM.

darkphoenix
  • 2,147
  • 3
  • 13
  • 14
  • 31
    +1 for referencing the license change. Gotta learn a new PDF library now... – Mayo Apr 04 '11 at 21:31
  • 1
    Any place where 4.1.6 version of iTextSharp can still be downloaded? Are there any issues why this older version should not be downloaded? – Rasto Jan 05 '14 at 23:56
  • 1
    @drasto I found this via Google: https://github.com/itextsharper/iTextSharp-4.1.6 Also, it seems you can get older versions via NuGet. I haven't confirmed this. – darkphoenix Jan 31 '14 at 20:04
39

iTextSharp http://itextsharp.sourceforge.net/

Complex but comprehensive.

itext7 former iTextSharp

live2
  • 3,771
  • 2
  • 37
  • 46
ine
  • 14,014
  • 8
  • 55
  • 80
37

Have a look at PDFSharp

It is open source and it is written in .NET, I use it myself for some PDF invoice generation.

Lord Darth Vader
  • 1,895
  • 1
  • 17
  • 26
  • 8
    PDFsharp is issued with [MIT license](http://en.wikipedia.org/wiki/MIT_License). (Very permissive) – bretddog Nov 13 '11 at 23:40
  • PDFSharp(MigraDoc) was super easy to get started with. I had the output I desired within an hour or two. – Chuck Savage Apr 23 '12 at 21:43
  • Guys, does PDFSharp allow you to create a PDF form, so that users can enter data directly into the form fields and email it back to us? I was not able to see anything like this on their features page, but it did say limited AcroForm support. What is AcroForm? The same thing? – Fandango68 Mar 18 '14 at 00:14
  • Is this project unsupported nowadays? – Johnny_D Jun 30 '14 at 11:48
  • This samples shows how to create a new document from two existing PDF files. http://www.pdfsharp.com/PDFsharp/index.php?option=com_content&task=view&id=34&Itemid=45 – Andrei Krasutski Jan 11 '21 at 08:20
4

Well, free and not-for-free, I use WebSuperGoo ABCpdf .NET component, that I just love it!

not-for-free because you need to pay for it.

for free because even if you have to pay, they have a trial version and you can request a free license if you do not mind that, in your site show "This site uses WebSuperGoo ABCpdf .NET component" with a link to their website.

I did that and I got a free license (version 5 in that time) so, I can say that it works (even if the website is no longer online) - I still have and use the component ~:)

A wonderful thing that I love with this is that you can do everything that you can thing off with this, create PDF forms and dynamically fill them and send to user by mail or have them to download it, create a pdf from scratch, convert HTML pages into PDF, etc etc etc, please read the documentation, it is a wonderful component.

balexandre
  • 73,608
  • 45
  • 233
  • 342
2

I strongly recommend: iTextSharp

Przemek
  • 795
  • 8
  • 17
1

I have used Gnostice in the past and found them to be very good.

http://www.gnostice.com/PDFOne_dot_Net.asp

Khadaji
  • 2,147
  • 2
  • 17
  • 19
0

Amyuni PDF Converter .Net can also be used for this. And it will also allow you to modify existing files, apply OCR to them and extract text, create raster images (for thumbnails generation for example), optimize the output PDF for web viewing, etc.

Usual disclaimer applies.

yms
  • 10,361
  • 3
  • 38
  • 68
0

There is a new project, RazorPDF which can be used from ASP.NET MVC. It is available as nuget package (search for RazorPDF).

Here is more info: http://nyveldt.com/blog/post/Introducing-RazorPDF

IMPORTANT UPDATE as @DenNukem pointed out, it depends on iTextsharp, I forgot to edit answer when I found that out (when I tried to use it), so if your project is not open source and eligible for their AGPL licence, it will probably be too expensive to use.

dumbledad
  • 16,305
  • 23
  • 120
  • 273
Goran Obradovic
  • 8,951
  • 9
  • 50
  • 79
  • 4
    Warning: depends on iTextsharp, which is an AGPL component and requires undisclosed commercial license to be used without AGPL restrictions. – DenNukem Jan 19 '13 at 17:10
  • 2
    Yeah, and I asked for iTextsharp quote for one server, almost $2000, so this is no go :( – Goran Obradovic Jan 19 '13 at 20:26
  • 1
    Thanks for finding out the price, saves me a bit of time there. I'm leaning towards PDFJet now, as their free version seems to fit my needs for now. – DenNukem Jan 20 '13 at 21:15
  • RazorPDF will work with LGPL-version of iTextSharp, just use NuGet-package https://www.nuget.org/packages/iTextSharp-LGPL/ – Toft Apr 24 '14 at 07:35
0

I have posted a sample of how to use iTextSharp in one of my blogs:

http://devpinoy.org/blogs/marl/archive/2008/02/14/create-pdf-in-c-2008-a-pdf-sample-app-for-grade-1-pupils.aspx

MarlonRibunal
  • 4,009
  • 3
  • 31
  • 37
0

For this i looked into running LaTeX apps to generate a pdf. Although this option is likely to be far more complicated and heavy duty than the ones listed here.

Simon P
  • 1,196
  • 1
  • 12
  • 26
0

Docotic.Pdf library can be easily used to create PDF files at runtime. The library can also modify existing PDF documents (extract text/images, append pages, fill form fields, etc.)

Samples for common tasks are available on the library site.

Disclaimer: I work for Bit Miracle.

Bobrovsky
  • 13,789
  • 19
  • 80
  • 130
  • DocoticPdf can be used to do what OP is asking. However this answer is misleading when it says easily. Don't get me wrong if you like frittering away days placing lines of text/text boxes at specific coords to build a simple invoice then you'll love DocoticPdf. DocoticPdf doesn't have useful concepts for creating PDF documents like templates, reusable page components or even a way to simply implement tables. It does have a lot of features for reading PDFs, creating interactive forms and other features, but they are lacking useful documentation and the samples are overly simple and not helpful. – DVS Jul 16 '21 at 23:01
  • @DVS Thank you for the feedback. The library indeed does not provide an API for creating tables. At the same time, you can reuse page components (see PdfXObject). You can also make copies of pages and documents. The library comes with a free HTML to PDF add-on that you can use to create invoces and similar documents. Please feel free to contact support@bitmiracle.com with a request for a sample code or a question about any unclear/incomplete documentation. – Bobrovsky Jul 25 '21 at 08:27
  • Docotic.Pdf now provides the layout add-on supporting tables, paragraphs, paging and so on: https://bitmiracle.com/pdf-library/create-pdf.aspx – Vitaliy Shibaev May 31 '23 at 05:09
-1

I have used (iTextSharp) in the past with nice results.

Knobloch
  • 463
  • 1
  • 6
  • 14
-2

How about iTextSharp?

iText is a PDF (among others) generation library that is also ported (and kept in sync) to C#.

Francisco Canedo
  • 1,980
  • 2
  • 13
  • 16