Jump to content

Object tag doesn't display PDF


Recommended Posts

This is strange but recently my page stopped displaying PDFs using the object tag.  Nothing has changed on the page (in fact, I haven't worked with it in a very long time and there's no one else besides my supervisor who can edit it; I'm 99.99999% sure he hasn't touched it either).  I guess what I want to ask is if there's anything that looks out of place with my code:

$x = 0;
foreach ($arrPDF as $pdf) {
	echo "<object id='bulletin".$x."' data='../path/".$pdf."' type='application/pdf'>\n";
		echo "<span class='error'>Error: Could not load PDF.  Your browser does not support embedded objects.</span>\n";
	echo "</object>\n";

This code used to work, then just seemingly at random one day, it decided not to.  Used to display the PDFs, now I just get the error message.

Any suggestions?  I've already tried updating the browser.  I've tried it in FireFox, Chrome, and Edge.  None of them display the PDFs.  Everything I've seen online about the <object> tag suggests this code should be just fine.  Is there a different/better way to embed a PDF that I'm not finding?

Link to comment
Share on other sites

  • 3 weeks later...

They're... a bad cover for a bad design decision in the most cases you see them used. In this example, you might be able to leverage the native browser PDF viewers with an iframe. Give it a bit of science.

Link to comment
Share on other sites

That was the days of html4 with strict doctype no longer supporting it, it was my main gripe as there was not cross browser support for anything else similar, so you had to use transitional doctype which allowed iframes. Then whoever realised what a major blunder they made, and it was resupported in html5

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...