如何将HTML内容转换为PDF而不会丢失使用Java的格式?

问题描述:

我有一些HTML内容(包括格式标签,例如 strong ,图片等)。在我的Java代码中,我想将此HTML内容转换为PDF文档而不用丢失HTML格式。

I have some HTML content (including formatting tags such as strong, images etc).In my Java code, I want to convert this HTML content into a PDF document without losing the HTML formatting.

无论如何在Java中使用iText或任何其他库吗?

Is there anyway to do it in Java (using iText or any other library)?

我会尝试 DocRaptor.com 。它以任何语言将html转换为pdf或html为xls,并且因为它使用Prince XML(不需要支付昂贵的许可费),所以质量比其他选项好很多。它也是一个网络应用程序,因此无需下载。轻松解决漫长而令人沮丧的编码问题。

I would try DocRaptor.com. It converts html to pdf or html to xls in any language, and since it uses Prince XML (without making you pay the expensive license fee), the quality is a lot better than the other options out there. It's also a web app, so there's nothing to download. Easy way to get around long, frustrating coding.

以下是一些例子:
https:/ /docraptor.com/documentation#coding_examples