Reputation: 1729
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>
I have found an solution here on StackOverflow that I have used. Works great!
Upvotes: 11
Views: 18321
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
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