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.
This question is related to
c#
html
css
pdf
pdf-generation
It's not open source, but you can at least get a free personal use license to Prince, which really does a lovely job.
It's not open source, but you can at least get a free personal use license to Prince, which really does a lovely job.
It's not open source, but you can at least get a free personal use license to Prince, which really does a lovely job.
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
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.
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
It's not open source, but you can at least get a free personal use license to Prince, which really does a lovely job.
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.
You could try my wkhtmltopdf wrapper: https://github.com/pruiz/WkHtmlToXSharp ;)
Source: Stackoverflow.com