Jump to content
ShadowMage

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";
	$x++;
}

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?

Share this post


Link to post
Share on other sites

I'd suggest using an iframe instead.

Share this post


Link to post
Share on other sites

Totally forgot I posted this until I was asked about it again this morning...

On 7/31/2020 at 5:44 PM, Ingolme said:

I'd suggest using an iframe instead.

I thought iframes were deprecated or not recommended?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

ah, ok.  I'll give it a shot with iframes then.  Thanks guys.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...