How to create PDF in ASP.NET

2020-06-19 05:50发布

问题:

I have seen lot of threads on it and really no good answer anywhere. Or rather none suit my situation. We need to print Business Letter for given list with mail merge facilities. Client is not willing to spend $$ On paid ASP.NET control to make PDF. so I opt for WKHTMLtoPDF and it works fine for us until one day client try to get PDF of 100+ leads, resulting in complete failure of PDF generation. It works just fine with 10-20 page PDF, but not for 100.

Is there any Tips & Trick to improve performance ? We are using Cloud hosted IIS 7 with ASP.NET 4, if that matter.

回答1:

PDFSharp library is really a nice one!

I have used it for quite a while now, and I find it flexible enough to fulfill your needs.

However there are some aspects of using it as a "standalone library" - e.g creating tables is a headache and there aren't much text formatting options. It is much better to mix it together with MigraDoc (an extension library for PDFSharp).



回答2:

If you're looking for a really free (as in "free of worries") library, choose iTextPDF versions prior to version 4.1.7, as they state in the ByteScout blog.

From the ByteScout blog:

iTextSharp 4.1.6 DLL only: itextsharp-4.1.6-dll.zip
iTextSharp 4.1.6 Source Code (C#): itextsharp-4.1.6.zip

I'm not sure I understand your problem but couldn't you generate docx documents and get the same results?



回答3:

For all, I use http://wkhtmltopdf.org/ to create HTML to PDF, my ASP.NET code generate the HtML file then I create HTML to PDF and it is done, much easier than using itextpdf's Table and td structure to get things in better space. I found it easy and fast once you get your stuff aligned properly.

library has improved since original question asked and it performs better now.



回答4:

here is good tutorial http://www.codeproject.com/Articles/20640/Creating-PDF-Documents-in-ASP-NET