Generating Pdf from webpage in asp.net

2019-05-25 07:52发布

问题:

Could you give me some recommendations on free/Openspurce library etc that could be integrated on asp.net application to Generate Pdf out of Html fragments. I will be generating Invoices that is displayed in DataGrid and tables. Is there some readily available library that would print the whole Table with Datagrid into Pdf. ITextSharp seems nice but i will have to do the tough work of adding tables and blah blah when everything is already in the webpage. this is a possible duplicate but it generates pdf from Full page which is not desired Possible duplicate question

回答1:

ITextSharp does almost what you ask and is Open Source, however the API for conversion process has not been touched for years and is outdated. I therefore would recommend a commercial product.

Something like Winnovative HTML to PDF Converter

To be honest I look at it like this, you can save money by buying a licence for a commercial product rather than spending days developing a solution yourself.

Edit If it is for generating invoices alone then I would use iTextSharp as it does not take long to learn the basics. However if you want to be able to convert a full rich webpage into a PDF then go down the commercial route.



回答2:

These links may help:

Convert HTML to PDF in .NET

Generate PDF from ASP.NET from raw HTML/CSS content?

Creating PDF Invoices - Are there any templating solutions?



回答3:

When doing invoices, I usually go a slightly different way, by starting with Aspose.Words and using the nested mail merge feature.

Another option could be the HTML to PDF feature of Aspose.Pdf.

Both libraries are commercial only, I don't know whether this is appropriate for your project.