[OJS 3.1.1.4] How to embed a pdf file in an iFrame

Hi,
How do you embed a pdf file in an iFrame? Apparently you can’t use the same method you use when you insert images in your html file. If we use the same method it will start downloading the pdf when opening the articlle and not show it in the article.
We’re running OJS 3.1.1.4
Best
Niels Erik

Hi @nef,

Do you mean within a HTML gallery, where the PDF is uploaded as a dependent file?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher
Yes, we have a html page with an iFrame. In that iFrame we’re trying to link to a pdf file, but the link doesn’t work after being published.
We have uploaded the pdf file via the HTML > Edit under Galley


Best
Niels Erik

Hi @nef,

Have you tried using an <object> element instead of an <iframe>? See e.g.: https://stackoverflow.com/questions/19654577/html-embedded-pdf-iframe

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher
Unfortunately, the object element did not solve the problem.
When I save the html page and associated pdf files locally on my own computer, the iframe element works fine in all my browsers. The problem arises when I upload the page and its pdf files into OJS.
Best
Niels Erik

Interesting. Do you have sample or demo?

I can replicate the behavior reported by @nef. Iframes and embed objects work fine locally, but are not able to find files once files are uploaded to OJS. Just to be clear, this applies to HTML galleys.
Here’s a sample code:

<html>
<body>

Iframe example:

<iframe
    src="01.pdf#toolbar=0&view=fitH"
    width="30%"
    border="0"
></iframe><br>

object embed example

<object data="01.pdf" type="application/pdf">
<embed src="01.pdf" type="application/pdf" />
</object>

</body>

HI all,

I would suggest checking whether it’s the HTTP headers that are preventing the PDF from being embedded. These are set in lib/pkp/classes/file/FileManager.inc.php in the downloadByPath function. In particular, I’d suggest looking at the Content-Disposition header – perhaps suppressing this will resolve it. (This will have side-effects – but if it does fix the PDF problem, I can suggest some next steps.)

Regards,
Alec Smecher
Public Knowledge Project Team