This website uses cookies to ensure you get the best experience. Learn More.
Visual Preview in Liferay DXP: Custom Portlet
Liferay provide OOTB features for Preview of Documents (PDF, Word, Image), Media (Audio and Video) in Document and Media Portlet. The same is available after installing following components
Post installation , their path needs be added and enabled in Liferay ( Server Administration --> External Services). If we need to develop this in custom portlet , here is the solution for the same.
Custom Portlet Solution:
1. Create Portlet and write custom code to check what type of file it is ( Doc or Video etc.)
For PDF and Images
boolean hasPDFImages = PDFProcessorUtil.hasImages(fileVersion);
boolean hasAudio = AudioProcessorUtil.hasAudio(fileVersion);
2. Generate preview URL for different file types
For Audio:
previewFileURLs[0] = DLUtil.getPreviewURL(fileEntry, fileVersion, themeDisplay, previewQueryString)
3. Use preview URLs on JSP ( used angular js in our case)