I have a link to a PDF file hard-coded on an HTML page, but it downloads the PDF on smartphones rather than displaying it. How can I make it to display on screen instead?
Many major browsers do not support that. I think none of the major browsers do. PDF was not designed for use in the internet.
I think that what you need to do is to convert the PDF to HTML, outside of the website, then upload the HTML file into your website.
All of my desktop browsers show PDFs.
It’s usually up to the website visitor to say whether PDFs should be downloaded or viewed in the browser.
To display a PDF on your web page instead of having it download, you can use the <object>
tag with an <iframe>
as a fallback. Here’s a simplified example you can embed in your HTML:
<object data="your-pdf-url.pdf" type="application/pdf" style="height: 800px; width: 100%;">
<iframe src="https://docs.google.com/viewer?url=your-encoded-pdf-url&embedded=true" style="height: 800px; width: 100%;" frameborder="0"></iframe>
</object>
Replace your-pdf-url.pdf
with the actual URL of your PDF. Make sure the URL in the iframe
src is URL-encoded.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.