LibreOffice 4.4.3 - Accessing Documents with jodconverter on different server

1.3k views Asked by At

I´m running a simple Java Application (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.

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"

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?

1

There are 1 answers

0
DRCB On BEST ANSWER

You cannot access remote files this way using simple File class.

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. See example here: connecting to shared folder in windows with java