【问题标题】:LibreOffice 4.4.3 - Accessing Documents with jodconverter on different serverLibreOffice 4.4.3 - 在不同服务器上使用 jodconverter 访问文档
【发布时间】:2015-06-12 15:57:46
【问题描述】:

我正在运行一个简单的 Java 应用程序 (JDK 1.8)。我的主要目标是访问文档(不同格式),转换为 PDF,然后使用 PDFClown 计算页数。

我可以通过在我的项目目录(在我的计算机上)中引入 Documents 来做到这一点。问题是当我尝试访问另一台服务器上的文档时。

org.artofsolving.jodconverter.office.OfficeException:无法加载 文档:不支持的 URL:“类型检测失败”

这是我的代码:

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

我做错了什么?

【问题讨论】:

    标签: java libreoffice jodconverter


    【解决方案1】:

    您无法使用简单的File 类以这种方式访问​​远程文件。

    您必须mount your folder as network drive 并使用普通文件系统路径访问文件。

    或使用特殊库通过 SMB 协议传输文件而无需挂载。 请参阅此处的示例:connecting to shared folder in windows with java

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-24
      • 2013-11-23
      • 1970-01-01
      相关资源
      最近更新 更多