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 “Contribution org.nuxeo.ecm.platform.preview.restAPI.contrib–restlets “). 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:
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).