Score:0

How do I output an embed of a private file PDF in views

fr flag

What I am trying to do is embed a pair of PDF files on a page using a View; however because they are uploaded to the private file store I think I am on to a loser.

My preferred desire is to have the PDF viewable on the page generated by the View, but that they can be clicked on and downloaded as well.

I am using Drupal 10

I have a content type where the user uploads two separate PDF’s into two separate ‘file’ entity slots. They are both saved a private rather than public files.

I have the view created (which is also restricted to the relevant roles) and have re-written the output for each one as

<object data="{{ field_[PDFname] }}" type="application/pdf" width="100%" height="500px">
      <p>Unable to display PDF file. <a href="{{ field_[PDFname] }}">Download</a> instead.</p>
    </object>

No embed occurs though and each time it falls back to the download option, presumably as I overlooked that object is not a permitted html tag.

I have also tried Embedded Google Docs Viewer but it fails because the PDF is set to private and not public

I also tried to set up Media PDF Thumbnail to see if there was a way around, however I struggled to even get it set up? I tried to follow the guide on the Drupal Contributed Modules pages and could not even set up a media entity view mode (I am probably overlooking something obvious)

Is it possible to embed a PDF in this way? Is there a pdf viewer that would achieve this?

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.