Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google chrome does not show PDF files in iframe

I use Pdf.js, I get base64 file from web service (this.attachmentSource), and when I want to add var iframe = "<iframe width=800 height=550 src='" + this.attachmentSource + "' > </iframe>",For some pdfs in google chrome I get iframe empty, but in Mozila everything work fine, who can explain this mystery?

like image 690
Vahe Galstyan Avatar asked Sep 10 '25 17:09

Vahe Galstyan


1 Answers

I happened to notice: server Response Header:

x-frame-options: DENY

The DENY option is the most secure, preventing any use of the current page in a frame. More commonly, SAMEORIGIN is used.

I was using AWS CloudFront with a Lambda@Edge function already, so I found a solution here: Configuring X-Frame-Options Response Header on AWS CloudFront and S3

If you are using a different server stack, you will have to adjust your server response headers accordingly.

like image 68
Max Reeder Avatar answered Sep 13 '25 08:09

Max Reeder