【问题标题】:How to open a Protected word document using Openoffice api with java?如何使用 Openoffice api 和 java 打开受保护的 word 文档?
【发布时间】:2015-03-20 00:55:04
【问题描述】:

我正在尝试使用 open office 打开“.docx”文档,但我不知道如何使用 open office java api 打开受密码保护的“.docx”文件。

请建议我必须使用哪些属性来访问受密码保护的“.docx”文件。

当我尝试使用以下属性值打开时,我得到了 IllegalArgumentException

     PropertyValue[] loadProps = new PropertyValue[3];
        loadProps[0] = new PropertyValue(); 
        loadProps[0].Name = "FilterName"; 
        loadProps[0].Value = "StarOffice XML (Writer)"; 
        loadProps[1] = new PropertyValue();
        loadProps[1].Name = "PassWord";
        loadProps[1].Value = "abcdef";
    Object objectDocumentToStore = xcomponentloader.loadComponentFromURL(loadUrl, "_default", 0, loadProps);

例外

com.sun.star.lang.IllegalArgumentException: URL seems to be an unsupported one.
at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:180)
at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:146)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:338)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:307)
at com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:94)
at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:642)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:154)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:136)
at com.sun.proxy.$Proxy3.loadComponentFromURL(Unknown Source)
at com.pravridh.puneeth.DocumentToPdfWithFilterData.main(DocumentToPdfWithFilterData.java:49)

【问题讨论】:

    标签: java apache openoffice.org


    【解决方案1】:

    只需编写此代码即可打开文档

    String cmds[] = new String[] {"cmd", "/c",
         "C:\\Users\\PC\\Desktop\\EA01.pdf"};
        try {
            Runtime.getRuntime().exec(cmds);
        } catch (IOException ex) {
            Logger.getLogger(secretry.class.getName()).log(Level.SEVERE, null, ex);
        } 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多