views:

4422

answers:

3

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,

+1  A: 

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.

Mauricio Scheffer
Many thanks!! I'll check these out.
Graphain
+3  A: 

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

We wrote a small tutorial here.

Mic
Does this work for ASP.NET/IIS?
Khalil Dahab
Is this by any chance programmable with c# ... I only see command line usages ?!
jalchr
This looks the most promising so far.
Graphain
+1  A: 

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

Constantine