java iText 5.0.0 RTF 和 HTML 去哪儿了?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1876678/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 18:19:50  来源:igfitidea点击:

iText 5.0.0 where did RTF and HTML go?

javaitext

提问by hypercube

This question may seem stupid, but, so be it! I have a stupid problem then :-). Well, my problem is this : using this code

这个问题可能看起来很愚蠢,但是,就这样吧!我有一个愚蠢的问题:-)。好吧,我的问题是:使用此代码

//PDF generation

PdfWriter.getInstance(document,
new FileOutputStream("PDFFile.pdf"));

//RTF generation

RtfWriter2.getInstance(document,
new FileOutputStream("RTFFile.rtf"));

//HTM generation

HtmlWriter.getInstance(document,
new FileOutputStream("HTMLFile.htm"));

(and some other lines) with iText version 2.1.7, every computer geek is able to produce files in PDF, RTF or HTM file formats from his Java code. Now, i've upgraded iText to latest version (5.0.0) and i am unable to locate RtfWriter2 (or old RtfWriter) or HtmlWriter. To be concise, i was wondering if anyone has any idea if the support for those file types was even maintained, since every search on web-search engines obviously pointed me to previous versions of iText, where, apparently, one was able to do everything. Any hints on the matter?

(和其他一些行)使用 iText 2.1.7 版,每个计算机极客都能够从他的 Java 代码生成 PDF、RTF 或 HTM 文件格式的文件。现在,我已将 iText 升级到最新版本 (5.0.0),但无法找到 RtfWriter2(或旧的 RtfWriter)或 HtmlWriter。简而言之,我想知道是否有人知道对这些文件类型的支持是否得到维护,因为网络搜索引擎上的每次搜索显然都将我指向了 iText 的以前版本,显然,在那里,人们可以做任何事情. 关于此事的任何提示?

回答by Ash

According to the iText website, in v5.0.0 they deliberately removed the RTF and HTML writers. On their history page (http://itextpdf.com/content/changelogs), they say:

根据 iText 网站,在 v5.0.0 中,他们故意删除了 RTF 和 HTML 编写器。在他们的历史页面(http://itextpdf.com/content/changelogs)上,他们说:

"The toolbox and RTF support have been removed: they are now in a separate project at SourceForge."

“工具箱和 RTF 支持已被删除:它们现在位于 SourceForge 的一个单独项目中。”

I believe this is the link to the new separate iText RTF project: http://sourceforge.net/projects/itextrtf

我相信这是新的独立 iText RTF 项目的链接: http://sourceforge.net/projects/itextrtf

And according to this thread: http://itext-general.2136553.n4.nabble.com/HTML-to-RTF-td2161984.html, the HTML support is taken over by the xhtmlrenderer project at https://xhtmlrenderer.dev.java.net(update: dead link. The project appears to have been renamed "Flying Saucer": new home at http://code.google.com/p/flying-saucer/, source at https://github.com/flyingsaucerproject/flyingsaucer).

根据此线程:http: //itext-general.2136553.n4.nabble.com/HTML-to-RTF-td2161984.html,HTML 支持由位于https://xhtmlrenderer.dev的 xhtmlrenderer 项目接管.java.net(更新:死链接。该项目似乎已更名为“飞碟”:位于http://code.google.com/p/flying-saucer/ 的新家,来源在https://github。 com/flyingsaucerproject/flyingsaucer)。

回答by demongolem

iText's rtf capabilities are still around. I would just like to add more information because the prior answers did not completely state what you have to do.

iText 的 rtf 功能仍然存在。我只想添加更多信息,因为先前的答案并未完全说明您必须做什么。

First, visit http://mirrors.ibiblio.org/pub/mirrors/maven2/com/lowagie/itext-rtf/2.1.7/itext-rtf-2.1.7.jarto get itext-rtf.jar. This has the entire rtf package, however it is not sufficient to work with RTF documents. One class needed quite commonly when using the rtf package is com.lowagie.text.Document which is not included in the itext-rtf.jar distribution.

首先访问http://mirrors.ibiblio.org/pub/mirrors/maven2/com/lowagie/itext-rtf/2.1.7/itext-rtf-2.1.7.jar获取itext-rtf.jar。这有整个 rtf 包,但是它不足以处理 RTF 文档。使用 rtf 包时非常常用的一个类是 com.lowagie.text.Document,它不包含在 itext-rtf.jar 发行版中。

Secondly, visit http://grepcode.com/snapshot/repo1.maven.org/maven2/com.lowagie/itext/2.1.7. Here you want to download itext-2.1.7.jar. This is the itext jar file you will need in order to work with the iText-rtf library. This is different than the current iText which now manages only pdf documents. At 5.0.0, rtf broke off and pdf kept the current numbering system. The rtf version number restarted and the rtf package now requires a different iText which will have the same version number as the rtf version number.

其次,访问http://grepcode.com/snapshot/repo1.maven.org/maven2/com.lowagie/itext/2.1.7。这里要下载itext-2.1.7.jar。这是使用 iText-rtf 库所需的 itext jar 文件。这与当前仅管理 pdf 文档的 iText 不同。在 5.0.0,rtf 中断,pdf 保留当前的编号系统。rtf 版本号重新启动,rtf 包现在需要不同的 iText,它的版本号与 rtf 版本号相同。

With these two downloads, you should be golden.

有了这两个下载,你应该是金色的。

EDIT

编辑

Other resources I know of:

我知道的其他资源:

  • IText Rtf API
  • Some Examples- Take with a grain of salt because it really is not Java and it is older, but some of the code snippets work anyway when you cut/paste
  • IText Rtf API
  • 一些例子- 持保留态度,因为它确实不是 Java 并且它更旧,但是当你剪切/粘贴时,一些代码片段无论如何都可以工作

I generally just answer the question/comment asked, however one can see the precarious position one might be in when doing new coding in itext-rtf. Proceed with caution.

我通常只是回答提出的问题/评论,但是人们可以看到在 itext-rtf 中进行新编码时可能处于不稳定的位置。谨慎行事。

回答by rtf

according to the maven repository, the last version of itext to support rtf is 2.0.8

根据 maven 存储库,支持 rtf 的 itext 的最后一个版本是 2.0.8

the itextrtf link on sourceforge in the previous answer seems to be vaporware, as there are no files available for download.

上一个答案中 sourceforge 上的 itextrtf 链接似乎是蒸气软件,因为没有可供下载的文件。

回答by prule

search.maven.org is a good resource for finding the jars you want. See http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.lowagie%22for all of the com.lowagie jars available - currently includes itext, itext-rups, itext-rtf

search.maven.org 是一个很好的资源,可以找到你想要的 jars。有关所有可用的 com.lowagie jar,请参阅http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.lowagie%22- 当前包括 itext、itext-rups、itext-rtf

Side note, this site also show what the latest versions are and when they were published - very handy!

旁注,该站点还显示最新版本是什么以及它们何时发布 - 非常方便!