question

MafievDev-0618 avatar image
0 Votes"
MafievDev-0618 asked JackJJun-MSFT commented

Can you recommend a PDF creation library in C#?

I'm about to start a new project and i will need to generate PDF files from C# code, what libraries do you recommend ?

dotnet-csharp
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@MafievDev-0618, you could search the keyword in Google like c# create pdf to know many methods to create pdf in c#. By the way, there are many solutions, do you have any questions about it?





0 Votes 0 ·
MoDeveloper avatar image
0 Votes"
MoDeveloper answered

I use PDFFlow library for almost a year now, and im satisfied with it because it has very unique and useful features.

this is a simple code in C# to create a PDF doc with text, image and a table

 var DocumentBuilder.New()   
   .AddSection()   
     .AddParagraphToSection("Your text goes here!")  
     .AddImage("image.png").SetWidth(250)  
   .ToSection().AddLine(300, Color.Red)  
 .ToDocument().Build("myPDF.PDF");  


136724-main-qimg-cce9224242433c7c3cee9e318a83a5d3.png



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Castorix31 avatar image
0 Votes"
Castorix31 answered

itext7 is fine itext7


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

cooldadtx avatar image
0 Votes"
cooldadtx answered

There are plenty of PDF libraries available. I recommend you take a look at 3 of them and decide which one has the features (and cost) that fits your needs. Pay careful attention to licensing rules because Adobe PDF is a commercial format and many libraries charge a fee to use them in commercial apps.

Things you should consider when deciding on a library (besides price):
- Functionality (are you manipulating an existing PDF, generating a new one)
- Support (how much support do you need and do you prefer dedicated paid support or free support)
- Do you want a mature library that may be older/slower or the fastest library available even if it might not be fully stable

iText7 (formerly iTextSharp) is probably one of the most popular libraries, is mature and has plenty of examples available for free. However it's licensing agreement changed between the (truly free) iTextSharp and iText7 (commercial) versions. Most of the older examples you'll see are for iTextSharp which is not compatible with the newer iText7. Furthermore if you are putting this into a commercial app it is not free anymore so you need to look at the cost if applicable to you.

Here's a link to the same exact question you asked in this forum back in Dec 2020 so the answers should still be valid as well.




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.