iText html 字符串到 .rtf 文件

iText html string to .rtf file

我想将 html 字符串转换为 .rtf 文件。当我做这样的事情时。

Document doc = new Document();
RtfWriter2.getInstance(doc, out);
HtmlParser hp = new HtmlParser();
hp.go(doc, in);

我收到一条异常消息:

<ExceptionConverter: java.io.FileNotFoundException: 
C:\Users\ddarellis.OTS\AppData\Roaming\JDeveloper\system12.1.3.0.41.140521.1008\DefaultDomain\resources\images\thyreos.jpg 
(The system cannot find the path specified)

这是因为我里面有一张图片html路径是相对的吗

有没有办法设置基本路径或完成我的工作的方法?

问题出在你的HtmlParser。解析器应检查相对路径的源属性,并用站点主机对其进行补充。然后您可以从 HTML DOM 树中单独下载图像。