简体   繁体   English

LibreOffice 4.4.3-使用jodconverter访问不同服务器上的文档

[英]LibreOffice 4.4.3 - Accessing Documents with jodconverter on different server

I´m running a simple Java Application (JDK 1.8). 我正在运行一个简单的Java应用程序(JDK 1.8)。 My main goal is to access a document (different formats), convert to PDF and then count the number of pages using PDFClown. 我的主要目标是访问文档(不同格式),转换为PDF,然后使用PDFClown计算页数。

I can do it by introducing Documents on directory of my project (on my computer). 我可以通过在项目目录(在计算机上)中引入文档来做到这一点。 The problem is when I try to access documents on another server. 问题是当我尝试访问另一台服务器上的文档时。

org.artofsolving.jodconverter.office.OfficeException: could not load document: Unsupported URL : "type detection failed" org.artofsolving.jodconverter.office.OfficeException:无法加载文档:不支持的URL:“类型检测失败”

Here is my code: 这是我的代码:

public static void main(String[] args) throws FileNotFoundException {
    OfficeManager officeManager = new DefaultOfficeManagerConfiguration().buildOfficeManager();
    officeManager.start();
    String path = "\\\\serverIP\\documents\\test.doc";
    OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager);
    String outFile = path.substring(0, path.lastIndexOf(".")) + ".pdf";
    converter.convert(new File(path), new File(outFile));
    Document document = new Document(new org.pdfclown.files.File(outFile));
    int countPages = document.getNumberOfPages();
    System.out.println(countPages);
    officeManager.stop();
}

What am I doing wrong? 我究竟做错了什么?

You cannot access remote files this way using simple File class. 您不能使用简单的File类以这种方式访问​​远程文件。

You must either mount your folder as network drive and access file using normal file system path. 您必须将文件夹安装为网络驱动器,然后使用正常的文件系统路径访问文件。

Or use special library to transfer files over SMB protocol without mounting. 或者使用特殊的库通过SMB协议传输文件而无需挂载。 See example here: connecting to shared folder in windows with java 在此处查看示例: 使用Java连接到Windows中的共享文件夹

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

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