Loading...
Area: Episerver CMS
Applies to versions: Episerver CMS UI 11.1.0 and higher & PDF Preview 1 and higher

Episerver PDF Preview

The Episerver PDF Preview add-on allows editors to preview PDF documents in the Episerver CMS edit view.

PDF_preview.png

In the PdfPreview package, there is a class named PdfFile which handles uploaded files with the .pdf extension.

Use case scenarios for using this package

The system does not have a model for handling PDF files

If the system does not have a model for handling PDF files, the default PdfFile model provided by the package is used. Editors can now preview PDF files in edit view without any extra steps.

The system already has a model for handling PDF files

By default, the ContentMediaResolver class from Episerver CMS Core gets the first matching media implementation type registered for an extension. If there is an existing type registered for “pdf”, the PdfFile media implementation in the Episerver package is used but in this case, the existing type should be chosen in this case.

To change this default behavior, a media resolver class named PdfContentMediaResolver is used to ignore the PdfFile type in the Episerver package and thus, the existing registered media type is the candidate.

PdfContentMediaResolver inherits ContentMediaResolver and overrides the Type GetFirstMatching(string extension) method to handle the business logic above. 

To turn on the PDF preview, the PDF media model must implement the IPdfFile interface. For example:

[ContentType(DisplayName = "PdfFile", GUID = "…", Description = "")]

[MediaDescriptor(ExtensionString = "pdf")]

public class PdfFile : MediaData, IPdfFile

{

}

Last updated: Apr 08, 2019