HomeGuidesAPI Reference
Submit Documentation FeedbackJoin Developer CommunityLog In

PDF Preview

This topic describes the Optimizely PDF Preview add-on, which lets editors preview PDF documents in the Optimizely CMS edit view.

PDF Preview is useful for websites where you manage multiple content items in PDF format.

How it works

When accessing the edit view in Optimizely CMS, you can select a PDF document from a media folder, to preview its content.

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

User scenarios

These are the typical user scenarios for adding PDF preview to your solution.

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 Optimizely 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 Optimizely 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 Optimizely 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
    {
    }

📘

Note

Due to limitations, after installing the add-on, you can preview only newly uploaded PDFs. You must upload existing PDFs again to be previewed.


Did this page help you?