liferay-document-preview-extension

Overrides Liferay Document Library full-content preview rendering via the DLPreviewRendererProvider OSGi SPI.

Updated Jul 24, 2026
One-click install
npx skills add https://github.com/gweone/agent-plugins --skill liferay-document-preview-extension-gweone
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: liferay-document-preview-extension
Source: https://github.com/gweone/agent-plugins/tree/main/plugin/sharpps-liferay/skills/liferay-document-preview-extension
Command: npx skills add https://github.com/gweone/agent-plugins --skill liferay-document-preview-extension-gweone

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Liferay's out-of-the-box Document Library preview renders PDFs and Office files as raster page-image flipbooks, so users cannot select or copy text, and Office previews silently fail when no LibreOffice conversion server is configured. This Skill explains how to replace that rendering with your own component without touching any Liferay core file. ## Core Features & Use Cases - OSGi Whiteboard Override: Register a higher service.ranking DLPreviewRendererProvider component keyed by mimetype to outrank Liferay's stock providers. - Preview vs. Thumbnail Clarity: Distinguish the extensible full-content preview SPI from the non-extensible raster thumbnail path so you change only what you intend. - Worked PDF Example: A complete reference component that renders selectable-text PDF previews in an iframe using DLURLHelperUtil.getPreviewURL, affecting both the View File page and the Search widget's view-content panel. - Use Case: A developer needs PDF previews with copyable text in a Liferay DXP intranet; they add one @Component to an existing bundle and deploy, with no core patches. ## Quick Start Ask the assistant to create a DLPreviewRendererProvider component that overrides the PDF preview in Liferay so users can select and copy text in the Document Library preview.

Frequently Asked Questions about liferay-document-preview-extension

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I override the Liferay Document Library PDF preview?

Register an @Component implementing DLPreviewRendererProvider with service.ranking higher than the stock provider and declare application/pdf in getMimeTypes. Liferay's single-value service tracker map then prefers your renderer for that mimetype without modifying any core file.

Why is the Liferay PDF preview an image instead of selectable text?

Liferay's stock DocumentPreviewRendererProvider renders PDFs as a flipbook of raster page images generated by PDFPreviewableDLProcessor using PDFBox. To get selectable text, override the provider and serve the file via DLURLHelperUtil.getPreviewURL in an iframe so the browser's native PDF viewer renders it.

Why does DOCX or Office preview not work in Liferay?

Non-PDF document preview requires conversion through an external LibreOffice/OpenOffice headless server, and OpenOfficeConfiguration.serverEnabled defaults to false. Enable it in Control Panel under Connectors > OpenOffice or via an OSGi config file, with a reachable soffice server.

Can a Liferay Client Extension implement DLPreviewRendererProvider?

No. DLPreviewRendererProvider is a portal-kernel SPI from document-library-api, so it must be implemented in a real OSGi module deployed to Liferay. Client Extensions run outside the OSGi runtime and cannot register such components.

Does overriding the preview also change the document thumbnails?

No. Thumbnails use a separate raster PNG lookup through ImageProcessorUtil and PDFProcessorUtil, not the DLPreviewRendererProvider SPI. Return null from getThumbnailDLPreviewRenderer in your component to leave card thumbnails on the stock path.

Why does a newly uploaded file show no preview on first view?

Preview generation is asynchronous: the DLProcessor's hasImages check returns false on first request and queues background generation. Check the DLFileVersionPreview table's previewStatus column (0 = success, 1 = failure) and the generated PNG files on disk to confirm state.