iText provides a way to convert HTML snippets to PDF using the HTMLWorker class. Unfortunately there isn’t much documentation on what you can do for styles. In order to figure this out I went through the source code. I’m putting it here so that I won’t have to do that again, and so that others will be able to gain something from my pain.
This is from iText 2.0.8
HTMLWorker supported tags
“ol ul li a pre font span br p div body table td th tr i b u sub sup em strong s strike h1 h2 h3 h4 h5 h6 img”
Tag | Attribute [iText methods] | Values |
---|---|---|
p | align [setAlignment()] | center, right, justify |
p | leading [setLeading()] | float or float, float |
p | before [setSpacingBefore()] | float |
p | after [setSpacingAfter()] | float |
p | extraparaspace [setExtraParagraphSpace()] | float |
If you find any more let me know and I’ll add them to the list.
Ken