0

Is there any documents and reference source codes for iText 5.0.3 (especially for HTMLWorker) ?

Another question is in iText 5.0.3, HTMLparser is obsoleted ?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
SkyEagle888
  • 1,009
  • 2
  • 18
  • 42

2 Answers2

0

Not sure about the iText part, but you can also use FlyingSaucer to convert HTML to PDF. Here's a simple blog with a bunch of examples.

For example HTML to PDF is as easy as:

ITextRenderer renderer = new ITextRenderer();
renderer.setDocument(new File("/file.html"));
renderer.layout();
renderer.createPDF(new FileOutputStream("/file.pdf"), true);

Note that it actually requires well formed XML. So you really need to feed it with XHTML. You can if necessary use an arbitrary HTML parser which produces a org.w3c.dom.Document which you in turn can feed to ITextRenderer#setDocument() so that you can convert tagsoups to PDF as well.

See also

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • The html parser renderer is not split into FlyingSaucer, FlyingSaucer is a complete different project maintained by other people then itext. FlyingSaucer does use iText for PDF eneration. – Redlab Apr 29 '11 at 16:35
  • No problem! It's a common mistake, we even get questions on the itext-question mailing list about how to do something with FlyingSaucer (which is a cool project by the way!) – Redlab Apr 29 '11 at 16:46
0

In 5.0.3 HTMLWorker exists, but does not support a lot of CSS. there is an example that converts movie xmls to pdf on the itextpdf.com examples pages.

With the next release of iText (5.1 or 5.0.7 not sure what it will be) there will be a separate jar the XMLWorker that will provide much more CSS support.

Redlab
  • 3,110
  • 19
  • 17