Arko Elsenaar
Arko Elsenaar

Reputation: 1729

"Failed to load PDF document" HTML5 Object

I am trying to display some PDF documents on my webpage, but I keep getting Failed to load PDF document in my browser. I have tried it in both Google Chrome and Mozilla Firefox (both latest versions). Whenever I inspect the object, and I open the src url directly in my browser, the path is correct and it downloads the PDF file.

Here's the code I'm using:

<object data="https://example.com/_f/user/pdf/my_file.pdf" type="application/pdf" width="100%" height="100%">
  <p>Alternative text</p>
</object>

Update

I have found an solution here on StackOverflow that I have used. Works great!

Upvotes: 11

Views: 18321

Answers (2)

Wave
Wave

Reputation: 572

I had the same problem and had to change theContent-Disposition attachment header.

I changed:

Content-Disposition: attachment; filename="filename.pdf"

TO

Content-Disposition: inline; filename="filename.pdf"

See also: How to force files to open in browser instead of download (pdf)?

Upvotes: 14

Alias Varghese
Alias Varghese

Reputation: 2172

I think something wrong with your url. can you try with this path?

<object data="http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/pdf_creation_apis_and_specs/PDFOpenParameters.pdf" type="application/pdf" width="100px" height="100%">
  <p>Alternative text</p>
</object>

Upvotes: 0

Related Questions