1

I have a need to be able to allow users to export their .doc files (which they upload) to a variety of formats. I got started on using OO SDK, and I set-up some custom filters using XSLT also. Everything works good and I am able to export word docs to pdf etc.

However I want to run this as a web service. I wish to run this conversion service on a dedicated node, so all file uploads by users wanting to convert their document will reach this dedicated node. My web app itself is PHP based. What is the best way to perform the conversion using OO SDK? I will have to store the resultant file in DB as well.

Do I need to run multiple instances of OO and feed each file to be converted to a specific instance? And, do I need to write a custom server to handle this, as I don't know if OO is multithreaded. Any advice greatly appreciated.

Colin Pickard
  • 45,724
  • 13
  • 98
  • 148
philly77
  • 519
  • 3
  • 8
  • 14
  • I tried to do this at my work but we had to drop it, since we couldn't get passable placement of document elements like nonstandard layouts and images from OOo. We're instead going to do pretty much the same setup except with MS Office as the converter. – Chris Jun 23 '09 at 06:49

2 Answers2

4

Using the cli dlls try with the following code

public conversion()
{
        unoidl.com.sun.star.uno.XComponentContext localContext =uno.util.Bootstrap.bootstrap();

        unoidl.com.sun.star.lang.XMultiServiceFactory multiServiceFactory =(unoidl.com.sun.star.lang.XMultiServiceFactory)localContext.getServiceManager();

        XComponentLoader componentLoader =(XComponentLoader)multiServiceFactory.createInstance("com.sun.star.frame.Desktop");

        XComponent xComponent = componentLoader.loadComponentFromURL(PathConverter(FileName1),"_blank", 0,new PropertyValue[] {MakePropertyValue("Hidden", true)});

        unoidl.com.sun.star.beans.PropertyValue [] propertyValues;
        propertyValues = new unoidl.com.sun.star.beans.PropertyValue[2];
        // Setting the flag for overwriting
        propertyValues[0] = new unoidl.com.sun.star.beans.PropertyValue();
        propertyValues[0].Name = "Overwrite";
        propertyValues[0].Value = new Any(true);
        // Setting the filter name
        propertyValues[1] = MakePropertyValue("FilterName", "HTML (StarWriter)");
        /*propertyValues[1] = new unoidl.com.sun.star.beans.PropertyValue();
        propertyValues[1].Name = "FilterName";
        propertyValues[1].Value = new uno.Any("HTML (StarWriter)"); // writer_pdf_Export  ,  swriter: MS Word 97 , HTML (StarWriter) ,*/

        XStorable xStorable = xComponent as XStorable;xStorable.storeToURL(PathConverter(FileName),propertyValues);
}

For a complete list of filternames to exports look into another answer I gave before.

jmayor
  • 2,725
  • 4
  • 29
  • 37
2

Have you looked into using JODConverter? It does all the heavy lifting for you.

Colin Pickard
  • 45,724
  • 13
  • 98
  • 148