使用 OpenOffice SDK 进行文档转换

发布于 2024-07-24 14:44:12 字数 360 浏览 6 评论 0原文

我需要能够允许用户将他们的 .doc 文件(他们上传的)导出为各种格式。 我开始使用 OO SDK,并且还使用 XSLT 设置了一些自定义过滤器。 一切正常,我可以将 Word 文档导出为 pdf 等。

但是我想将其作为网络服务运行。 我希望在专用节点上运行此转换服务,因此想要转换文档的用户上传的所有文件都将到达此专用节点。 我的网络应用程序本身是基于 PHP 的。 使用 OO SDK 执行转换的最佳方法是什么? 我也必须将结果文件存储在数据库中。

我是否需要运行多个 OO 实例并将每个文件提供给要转换为特定实例的文件? 而且,我是否需要编写一个自定义服务器来处理这个问题,因为我不知道 OO 是否是多线程的。 任何建议都非常感激。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

柠北森屋 2024-07-31 14:44:12

使用 cli dll 尝试使用以下代码

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);
}

有关要导出的过滤器名称的完整列表,请查看我之前给出的另一个答案。

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.

不羁少年 2024-07-31 14:44:12

您是否考虑过使用JODConverter? 它会为您完成所有繁重的工作。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文