Is there a more elegant way to host a PDF?

Sure, I can just link it and have that go to the page, but what if I don’t want it for DL (I know it’s the internet, so maybe I just want them to have to work for it). What if I want to inline it? I know there’s a few things for wordpress that do this, is there anything for Blocs?

It should be noted that most browsers only support the display of PDF’s as a sort of courtesy, the PDF format was never intended as a substitute for html. That said, if you want to display a PDF inline, you would have to display it in an iFrame. Just add a code widget and add the following code to your page:

<iframe src="yourPDF.pdf" height="1200" width="800" title="Iframe Example"></iframe>

For testing purposes, it’s often easier to upload the PDF’s you intend using to a folder on your server. You would then put the full URL of the relevant PDF in the iFrame code.

When embedding PDF’s this way be mindful of the size you set for your iFrame. The PDF will scale to fit inside the iFrame width, so if it’s too small, text may be difficult to read. This is the same PDF displayed at two different sizes on the same page:

You could just embed the PDF’s at a small size and then leave the browser to handle opening or downloading the PDF. When hovering over a PDF in an iframe, most browsers will display controls to allow for the handling of the content - this is how the controls look in Safari:

Screenshot 2020-07-10 at 15.38.29

Other browsers have a different layout.

To establish the correct height of your iframe, multiply the width by 1.414 (for A4 paper size) or 1.294 (for letter size paper) Observing these aspect ratios should ensure that your iframe doesn’t show scroll bars. Of course, if it’s a multipage PDF, you will see scroll bars so you can scroll through the document.

1 Like

I would have thought it might be an “elegant solution” if PDF could be viewed inside a popup modal but I am not in front of the computer at the moment to see if this is possible somehow.

I think you would have to still use the iFrame option, but inside a modal bric. I know iFrames are not the most elegant way of displaying anything in a modern website, but if someone wants the ability to both display AND download a PDF, this would appear to be the most practical solution.

Great recipe!