Open Source HTML to PDF Renderer with Full CSS Support
C#HtmlCssPdfPdf GenerationC# Problem Overview
I asked about getting iTextSharp to render a PDF from HTML and a CSS sheet before here but it seems like that may not be possible... So I guess I will have to try something else.
Is there an open source .NET/C# library out there that can take HTML and CSS as input and render it correctly?
I must reiterate... the library MUST be free and preferably something with a fairly liberal license. I'm working with basically no budget here.
C# Solutions
Solution 1 - C#
This command line tool is the business! https://wkhtmltopdf.org/
It uses webkit rendering engine(used in safari and KDE), I tested it on some complex sites and it was by far better than any other tool.
Solution 2 - C#
I've always used it on the command line and not as a library, but HTMLDOC gives me excellent results, and it handles at least some CSS (I couldn't easily see how much).
Here's a sample command line
htmldoc --webpage -t pdf --size letter --fontsize 10pt index.html > index.pdf
Solution 3 - C#
Solution 4 - C#
You could try my wkhtmltopdf wrapper: https://github.com/pruiz/WkHtmlToXSharp ;)
Solution 5 - C#
It's not open source, but you can at least get a free personal use license to Prince, which really does a lovely job.
Solution 6 - C#
Try ABCpdf from webSupergoo. It's a commercial solution, not open source, but the standard edition can be obtained free of charge and will do what you are asking.
ABCpdf fully supports HTML and CSS, live forms and live links. It also uses Microsoft XML Core Services (MSXML) while rendering, so the results should match exactly what you see in Internet Explorer.
The on-line demo can be used to test HTML to PDF rendering without needing to install any software. See: http://www.abcpdfeditor.com/
The following C# code example shows how to render a single page HTML document.
Doc theDoc = new Doc();
theDoc.AddImageUrl("http://www.example.com/");
theDoc.Save("htmlimport.pdf");
theDoc.Clear();
To render multiple pages you'll need the AddImageToChain function, documented here: http://www.websupergoo.com/helppdf7net/source/5-abcpdf6/doc/1-methods/addimagetochain.htm