• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Java API for RTF to DOCX Conversion

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please suggest me any Java API for RTF to DOCX conversion. I have tried the following utilities but could not find anything useful for my requirement.

Aspose.Words for Java
The issue that we face with Aspose.Words for Java library is that some of the images present in RTF file are blown up in DOCX file.

OpenOffice
We tried to use OpenOffice for our conversion, but found that it does not support saving in DOCX format.

Please find the message in the forum

Yes it is, support was added in 3.0, although you can't save in that format.

http://user.services.openoffice.org/en/forum/viewtopic.php?f=7&t=17889

Apache POI
The Apache POI Java APIs is used for manipulating various file formats based upon the Office Open XML standards (OOXML) and Microsoft's OLE 2 Compound Document format (OLE2).

But it does not support reading RTF. Please find the information that we got from forums.

No, POI has no provisions for reading RTF. But the basic structure of RTF isn't complicated. If you spend some time with the specification (such as there is) and study a few simple RTF files, you should be able to write code that parses the file contents and extracts the actual text.

https://coderanch.com/t/416976/java/java/read-rtf-file-display-console

No. RTF is not an OLE 2 Compound Document Format (hence the header error), nor is it a closed format, nor even binary and there are plenty of libraries that can read/write it. POI only covers "nitch" formats (OLE 2 Compound Document based).

http://apache-poi.1045710.n5.nabble.com/Reading-rtf-files-using-POI-HWPF-td2282390.html

JODConvertor

JODConverter is supporting DOCX as input but not as output format.

Please find the error trace when we tried converting RTF to DOCX.
Dec 27, 2010 8:16:51 AM com.artofsolving.jodconverter.openoffice.connection.AbstractOpenOfficeConnection connect
INFO: connected
Exception in thread "main" java.lang.IllegalArgumentException: unsupported conversion: from Rich Text Format to Microsoft Word 2007 XML

docx4j
docx4j is an open source Java library for manipulating OpenXML WordprocessingML documents, released under the Apache software licence.

It supports creating, reading and saving DOCX files and export them to PDF/HTML. But, it does not help in reading RTF file.

We have also come across utilities like Docmosis, Java2Word, javadocx and iText. But none of them helped in converting RTF to DOCX.

Any suggestion on this is much appreciated. Thanks
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the reason for wanting to do this conversion? I think every application that can open DOCX can also open RTF, so you're not gaining anything. But you're actually losing something because not every application that can open RTF can open DOCX.
 
Saravanan Iyyanar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ulf Dittmer,

We are currently reading xml and creating RTF using Java and delivering to user. Now we have requirement to deliver in DOCX format, so we thought of creating RTF and use any utility to convert to DOCX and deliver it to user
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, just so long as you're clear that DOCX is less widely usable than RTF.

Converting documents often results in reduced quality. If this was my problem, I'd adapt the existing RTF-generating code to generate DOCX using Apache POI instead.
 
Saravanan Iyyanar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ulf Dittmer Yes, we are also concerned about the quality when we convert from RTF to DOCX. But considering the time factor, we are trying this option. If we find any utility that can give us close conversion, we are fine with adhering to that utility. We found that Apache POI does not read RTF. So if we are going to read xml and create DOCX direclty as we are doing today for RTF, then we are planning to use Apache POI.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic