Hi everybody,

Easily I could set display for file entity (PDFJS or Embedded Google Document Viewer). But for Media entity reference I can set view mode: "Full content" (shows the file link) and "Media library" (shows file name).

Please advise how to display PDF media on a page?

Thanks in advance

Comments

wombatbuddy’s picture

Take a look to these modules: Entity PrintEntity PDFMedia PDF Thumbnail
(if they will not help, please try to rephrase your question).

johnpitcairn’s picture

It's all about view modes. You just need to go one level deeper with the media reference, and configure the image field on the media.

Configure the media type's "manage display" to use PDFjs or an embedded google docs viewer to display the file field.

Then that is what will display when you view the referenced media as "rendered entity" with that view mode. If you want to keep the full content and media library view modes as they are, you can create an additional media view mode and use that instead.

mitpatoliya’s picture

Before Drupal 8 & 9 you had to add explicit support for rendering pdfs via modules like PDF Render and Google Doc Viewer but as you are using Drupal 9 Media Manager module is already embedded. If you just set the default render in manage display settings of that field it should be able to render pdf in your browser easily.

Check this out

https://www.youtube.com/watch?v=63QD05wD3vg

johnpitcairn’s picture

There is no D8/9 core "Media Manager" module, it's core Media module.

The default media document view mode just renders a simple file link, not a PDF, and the browser loads the linked file as a standalone document. It's not rendering the PDF in Drupal. You lose all the site navigation, branding, etc. Saying you couldn't do this in core with file uploads before Drupal 8 is nonsense. It's just a file link.

This is not the same thing as rendering the PDF in the page, which is what something like the embedded GDoc field can do.