Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iText 5.0.0 where did RTF and HTML go?

Tags:

java

itext

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?

like image 494
hypercube Avatar asked Dec 09 '09 20:12

hypercube


People also ask

Is iText 5 open source?

iText was written by Bruno Lowagie. The source code was initially distributed as open source under the Mozilla Public License or the GNU Library General Public License open source licenses. However, as of version 5.0. 0 (released Dec 7, 2009) it is distributed under the Affero General Public License version 3.

What is the difference between iText and Itextpdf?

tl;dr: there is no difference!

What is the difference between Lowagie and iText?

Actually, there is no difference: in iText 2.1. 0. Create a PDF, go to properties and see "iText 2.1. 0 by lowagie.com" )) what seems to have happened in the evolution of the lib is that "lowagie" in the java package name, was replaced with "itextpdf".

Is iText 2 free?

We have a dual licensing business model. You can use the SDK at no cost if you open source the application you are integrating the iText SDK into per the terms of the AGPL license, or you can license iText commercially if you don't want to open source your entire application.


3 Answers

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:

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

I believe this is the link to the new separate iText RTF project: 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).

like image 55
Ash Avatar answered Sep 23 '22 04:09

Ash


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.

First, visit http://mirrors.ibiblio.org/pub/mirrors/maven2/com/lowagie/itext-rtf/2.1.7/itext-rtf-2.1.7.jar to 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.

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.

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

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.

like image 8
demongolem Avatar answered Sep 22 '22 04:09

demongolem


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

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

like image 1
rtf Avatar answered Sep 22 '22 04:09

rtf