繁体   English   中英

如何使用Openoffice api和Java打开受保护的Word文档?

[英]How to open a Protected word document using Openoffice api with java?

我正在尝试使用开放式办公室打开“ .docx”文档,但是我没有得到如何使用开放式办公室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)

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM