HTML转PDF思路

iText In Action 中写道 :“Does iText provide
HTML2PDF functionality?” The official answer is no. Usually you’ll get advice to use
another product; for instance, xhtmlrenderer, aka Flying Saucer—a project that is
built on top of iText.

In some cases, you don’t need a full-blown HTML renderer. Many web applications
come with a small HTML editor that allows users to post messages with limited
markup. For example, perhaps only <b> and <i> tags are allowed. Often these HTML
snippets are stored in a database or somewhere on the filesystem. The initial question
for HTML to PDF functionality could be rephrased as: “Can we insert those HTML
snippets into a PDF file using iText?” The answer is yes;

所以可以使用xhtmlrenderer结合iText完整实现整个HTML to PDF!!!!
部分HTML片段可以通过iText中HTMLWorker中method parseToList()解析。
iText5版本该类被废弃,不建议使用。除非你有强烈的欲望要使用。

你可能感兴趣的:(html)