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,

share|improve this question

3 Answers

up vote 6 down vote accepted

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.

share|improve this answer
Many thanks!! I'll check these out. – Matt Mitchell Feb 5 '09 at 13:14

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

We wrote a small tutorial here.

share|improve this answer
Does this work for ASP.NET/IIS? – Khalil Dahab Feb 22 '10 at 12:18
3  
Is this by any chance programmable with c# ... I only see command line usages ?! – jalchr Mar 29 '10 at 22:37
This looks the most promising so far. – Matt Mitchell Apr 28 '10 at 16:11
There is a C bindings library, which should in theory be usable from C# using P/Invoke, but I've had no luck succeeding yet: github.com/bamccaig/WkHtmlToPdfDflat. I've also tried writing a plain C program (from Linux, even) to directly test the C bindings, but even that has failed: code.google.com/p/wkhtmltopdf/issues/detail?id=614. – bamccaig May 17 '11 at 19:10

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.