Open Source HTML to PDF Renderer with Full CSS Support
Solution 1
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 2
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 3
Do you see :
They look as PrinceXML
Miguel Ventura
Updated on May 14, 2020Comments
-
Miguel Ventura almost 4 years
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.
-
Levitikon over 12 yearsYeah, and they put their logo on the output
-
Levitikon over 12 yearsDoesn't look like the standard edition is free anymore, "Licenses for ABCpdf .NET from only $329."
-
AffineMesh over 12 yearsThe free license is offered through a promotional scheme. If it disappears, try googling for 'websupergoo free licenses'. Note the offer is for single license only. If you need to purchase a license or additional licenses, the price is as Levitikon has said.
-
Bilal lilla about 12 yearswill you please explain how to use that library. any code in either C# / VB.net
-
Norman Ramsey about 12 years@Bilal, as it says in my answer, I've always used it on the command line and not as a library.
-
Bilal lilla about 12 yearsjust write that line that you use for conversion from html to pdf.
-
Gman almost 12 yearsIn fact, it also has library version and I've implemented .NET wrapper for it github.com/gmanny/Pechkin (also on NuGet).
-
Volatil3 about 11 years@NormanRamsey does it support RTL language based Custom TTF fonts by using @fontface?
-
PeterX almost 11 yearsYes, @AffineMesh could you please revise your text above saying the "standard edition can be obtained free of charge". Or simply add an extra note. Incidentally, I find their license somewhat confusing: "The Owner offers you a non-exclusive, non-transferable license on the terms of this Agreement". What does this mean - do I still have to get one?
-
Dilhan Jayathilake almost 10 yearsI tried the NuGet and it is great. Works perfectly.
-
Sean Chase over 9 yearsOutstanding! I tried this vs iTextSharp and AsposePDF. Aspose rendered horribly for me and iTextSharp just kept throwing exception after exception. wkhtmltopdf worked on the first try and rendered everything perfectly.
-
Norman Ramsey almost 9 years@mauvm fixed the link
-
Al Belmondo almost 9 yearsDoes this bring in styling and images?
-
Peter Wone almost 9 years@AlBelmondo - it definitely honours CSS defined in a header <style> block. There is a setting web.loadImages that takes a true/false value but I haven't managed to get images to load yet.
-
VFein over 8 yearsThe tuesPechkin library for wkhtmltopdf is great and thread safe, however, cannot process conversions concurrently -- which is my current problem.
-
Guru Stron over 8 yearsAlso Rotativa is using
wkhtmltopdf
under the hood too, if i understand correctly. -
Christian Neverdal almost 8 yearsThis answer should be deleted. The asker is clearly asking for an open source renderer.
-
Charlie Martin almost 8 yearsYes dear, let's start fretting about seven-year-old answers to closed questions.
-
Charlie Martin about 6 yearsGood, let's fret about TEN YEAR OLD questions now.
-
Stephanie about 6 yearsOur IronPDF Library builds upon the great work done in wkhtmltopdf. CSS is fully supported. IronPDF.com makes the process of adding PDF functions to a project quick and easily.
-
Will Marcouiller about 5 yearsBroken Link, again. :\