Maintain CSS styling when converting HTML to PDF in ASP.NET [closed]

天涯浪子 提交于 2019-11-28 21:59:49

Have a look at WKHTMLTOPDF. It is open source, based on webkit and free.

We wrote a small tutorial here.

Mauricio Scheffer

HTML / CSS support in iText / iTextSharp is very basic. It's just not the right tool to convert html to pdf. Take a look at these solutions instead:

These render html to an image. Then you can insert them in your PDF with iTextSharp.

Otherwise you could try converting HTML -> XSL-FO -> PDF, but including CSS there is a whole other thing.

Try PDF Duo .NET converter. You can apply for support if you need a special feature.

http://www.duodimension.com/html_pdf_asp.net/downloads/html_pdf_net.zip

ABCpdf provides two HTML rendering engines. One is based around the MSHTML version installed on the system. The other is based around the FireFox Gecko rendering engine.

So there's plenty of room for manouver if you want a particular set of features. It's very real world.

In terms of quality I would just say that we do get a lot of people settling on ABCpdf after trying a lot of different alternatives.

I work on the ABCpdf .NET software component so my replies may feature concepts based around ABCpdf. It's just what I know. :-)

Why not use online API? There are plenty of them available and they do the work well, which let you worry about your core work, not how to render a PDF correctly :)

You mention something "free". It depends on your usage, but most services offer free conversions to start with, ranging from 50 to 250 (and even more). Maybe it would be enough for you?

All you'd have to do then is a basic POST request to the service with your HTML data (or link), and you'll get a PDF in response.

Here are a list of API to convert HTML to PDF (not exhaustive):

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!