简体   繁体   中英

Any reference source codes or documents for iText 5.0.3?

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 ?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM