1

I want to display PDF-file on my cite, so it can be viewed online - without downloading - even on on mobile devices. Host just the file (like www.site.com/file.pdf) works only for computers. Would be best to do it in pure html, but if not possible, OK.

Have tried many options, like

<object data="pdf/sample.pdf#view=Fit" type="application/pdf" width="100%" height="400px"> </object>

or

<embed src="filename.pdf#toolbar=0" width="500" height="375">

All of them or still download on some devices, or give an error (eg. when using embed - "plugin not supported").

Would also be happy to work without google docs viewer, if possible. Any ideas?

1
  • Regarding your deleted question, what part of GitHub needs to access your site (which is blocked in your country domain)? Is is a GitHub Action? A GitHub pages which tries to deploy pages? What is happening on GitHub which needs to contact your site and is blocked?
    – VonC
    Commented Mar 16, 2023 at 14:36

1 Answer 1

3

This depends solely on client (browser) capabilities whether it supports embedded PDF or not. Mobile browsers usually does not support it.

If browser does not support embedded PDF, you would need to render PDF as image or html or something that the browser is capable of displaying. See Mozzila's PDF.js project https://github.com/mozilla/pdf.js

Similar questions:

Not the answer you're looking for? Browse other questions tagged or ask your own question.