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>

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?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.