Today we have a question about document preview. The default behaviour of the JSF app only gives you the preview of the main file. You don’t have preview for the attachments. But the good news is that technically, it relies on a REST API, so it’s pretty easy to call. Here’s an example from the default preview window:
To understand how this works, let’s take a look at the documentation. Since it’s quite old, it uses the restlet. So in Nuxeo Explorer you have to search for the restlet extension point.
The format of the URL is as follow:
So I have to find the right fieldPath to access my attachment. It’s stored in the schema files, as the first element of the files list (usual xpath would be files:files/1/file). Here’s what it looks like:
http://localhost:8080/nuxeo/restAPI/preview/default/2dc340b4-5a14-4fd9-afdb-dc4c1e09830e/files:files-0-file/ Note that the slash in the fieldPath has to be replaced by a dash.
Now you can have a preview of any file. The choice is up to you as to where/how to display it. I like the fancybox. I think it looks great and it’s really easy to set up. Here’s just a quick example:
Also something that you need to know: the HTML preview of any file is computed using converters. So if for some reason you cannot preview a file, you need to make sure there’s an HTML converter for it. We try to have as many as possible by default, but some file types are not covered (usually it’s because they are proprietary, undocumented file formats).