Reputation: 586
My server is node.js but I am sending out a URL to the PDF hosted on S3. Using Chrome, the PDF downloads automatically even when embedded in a div or iframe. How can I force it to be embedded?
A link to one PDF in my S3 bucket: http://ws902.s3.amazonaws.com/pdf_1367897334399.pdf
-
Code I'm using that works fine when it's a local PDF...
<iframe src="myfile.pdf" width="100%" style="height:20em"></iframe>
or
<div id="pdf"><object data="myfile.pdf" type="application/pdf"></object></div>
Upvotes: 7
Views: 6287
Reputation: 575
i using iframe and work for me.
baseURL : `${window.location.origin}/lib/pdfjs-2.10.377-dist/web/viewer.html?file=/`,
pdfS3Url : 's3File/202411/Terms.pdf',
<iframe
:src="baseURL + pdfS3Url[0]"
width="100%"
height="300"
type="application/pdf"
class="doc-wrap">
</iframe>
Upvotes: 0
Reputation: 575
To elaborate on Alex D's answer regarding node.js and uploading a public pdf to s3 using headers:
Upvotes: -3
Reputation: 586
The solution was to send file headers with the file to S3. S3 serves the files with the same mime type as it was uploaded. By default this is octet, so I changed it to application/pdf.
Using node.js and knox:
headers: { 'x-amz-acl': 'public-read','Content-Type': 'application/pdf' }
Upvotes: 10