1

I tried using the simple EditorKit option, but that doesn't seem to support all the RTF formats. So I turned into using either Tika,JODConverter or POI.

As of now I managed to make it work with JODConverter and openOffice by using this

 OfficeManager officeManager = new DefaultOfficeManagerConfiguration()
    .setPortNumbers(8100, 8101).buildOfficeManager();
    officeManager.start();
    OfficeDocumentConverter converter - new    
OfficeDocumentConverter(officeManger);
        try{
    File tempFile = File.createTempFile("tempRtf", ".rtf");
    BufferedWriter bw = new BufferedWriter(new FileWriter(tempFile));
    bw.write(rtfString);
    bw.close;
    File outputTempFile = File.createTempFile("otuputTepFile", ".html");

    converter.convert(tempFile, outputTempFile);

    return FileUtils.readFileToString(outputTempFile);

This works.

My problem is that I actually set up a server and close it, which takes a lot of time. I tried to see if I can bring up the process on the first run\report (I use it as a Handler in birt report) and then just to check if the process is running, if so use it to convert, and that's it, it'll save lots of time I see is wasted on initiating and closing process ( I don't care it will stay up) My problem is that it seems like these classes as noted here are not present on my version of JODConverter. After farther investigation, I found out that they are on the JODConverter 2.2 API and i use the 3.0 core-beta-4.

JODConverter seems to be kinda complex to a my simple need.

so if anyone knows how to start the office manger once and then just check if its up I'd love a code sample, and Of course if anyone got better solution than JODConverter to my need ill be glad to hear it.

EDIT: I need my Handler to do 2 things, 1. check if there is an instance of officemanager up, and connect to it (we skip the officeManager.start()) and 2. if the instance isn't up, then ill basically do what the code sample i wrote sent. This code is written in a BIRT Handler, so i can't create the officeManager globally and just share it, cause the handler class runs everytime i call birt engine. Maybe i can set up the officeManager in the Birt itself? then ill have the instance in the handler?

Peter Badida
  • 11,310
  • 10
  • 44
  • 90
sharon gur
  • 343
  • 5
  • 22

0 Answers0