Hi,
I am using ITextSharp to convert a HTML page to PDF.
However, ITextSharp prints the CSS in the STYLE declaration straight out, ignores stylesheets even when added programatically and only listens to some inline styles (e.g. font-size and color but not background-color).
Is there something I am missing with ITextSharp, or is there a better (and free) way of doing this conversion?
Thanks in advance,
-
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:
- http://stackoverflow.com/questions/340501/create-screenshot-of-the-page-with-watin-like-tool
- http://blog.taiki.be/index.php/2008/07/generating-screenshots-of-webpages-using-net/
- http://www.codegod.de/WebAppCodeGod/Screenshot-of-Webpage-with-ASP-NET-AID398.aspx
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.
Graphain : Many thanks!! I'll check these out. -
Have a look at WKHTMLTOPDF. It is open source, based on webkit and free.
We wrote a small tutorial here.
Khalil Dahab : Does this work for ASP.NET/IIS?jalchr : Is this by any chance programmable with c# ... I only see command line usages ?!Graphain : This looks the most promising so far. -
Try PDF Duo .NET converter. You can apply for support if you need a special feature.
http://www.duodimension.com/html%5Fpdf%5Fasp.net/downloads/html%5Fpdf%5Fnet.zip
0 comments:
Post a Comment