--- PRE Edit Section --- For anyone who want to generate pdf from html in simpler applications / environments I leave my old post as suggestion.Tues Pechkin https:// Pechkin/ or Especially For MVC Web Applications Rotativa https:// They both utilize the wkhtmtopdf binary for converting html to pdf.Which uses the webkit engine for rendering the pages so it can also parse css style sheets.They provide easy to use seamless integration with C#. It has the free and paid version, and really worth it. This library works fine when I run it locally on my machine, but on the hosting server, I am seeing the following error randomly. Cannot generate PDF: (exit code: 1)"Bear in mind that when we last checked winnovative was incompatible with IE9 (as they used the IE GDI rendering engine which was removed in IE9).The company that makes it sells the compiled binaries, but you are free to download and compile from source and use it for free.I managed to compile a pretty recent revision (for version 1.9) and I intend on releasing a binary installer for it in a few days, so if you're interested I can provide a link to it as soon as I post it.Edit (2/25/2014): Seems like the docs and site moved to
They fall into three categories: not really free, unacceptable dependencies like wkhtmltopdf or IE9, and the HTML Renderer for PDFSharp.
I can live with the dependency to wk Html To Pdf in this project so this solution was great - it renders the HTML beautifully. Net PDF library, there are numerous free HTML to PDF tools, many of which can run from a command-line. Poor support, very finicky as a result of its wrapper around the IE rendering engine, poor image quality and compression, limited ability to customize the request made to handle some more advanced usage scenarios (like supplying cookies and request headers).
One solution would be to pick one of those and then write a thin wrapper around that in C#. I suppose how well it works is subject to what you need it to do. The previous commenter must not have talked to the same support folks I did - they always wrote me right back and always had a solution for any issues we had.
I want to generate a PDF by passing HTML contents to a function.
I have made use of i Text Sharp for this but it does not perform well when it encounters tables and the layout just gets messy. @Adam Moszczyński: From Wikipedia: The LGPL allows developers and companies to use and integrate LGPL software into their own (even proprietary) software without being required (by the terms of a strong copyleft) to release the source code of their own software-parts.