PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, November 30, 2022

[FIXED] Why is google chrome blocking my pdf in iframe

 November 30, 2022     google-chrome, iframe, pdf     No comments   

Issue

I have an iframe with a src attribute set to a https pdf link. On firefox (99.0.1), my iframe displays correctly the pdf, but not on google chrome (101.0.4951.54). I have no extension installed on my google chrome, and found no errors or any logs in the console.

Chrome gives me a grey iframe like that: enter image description here (in english it says "This page has been blocked by Chrome")

I've went into the console, inside the network tab and here is the only useful information I've found: enter image description here


Solution

I had the same issue but only on CodePen, which is displaying everything in an iframe, which was probably causing problems.

Once I created my own html file, everything was working correctly.

Both codes work correctly:

<embed
  class="pdfobject"
  type="application/pdf"
  title="Embedded PDF"
  src="https://africau.edu/images/default/sample.pdf"
  style="overflow: auto; width: 100%; height: 100%;">

and

<iframe src="https://africau.edu/images/default/sample.pdf" width="500" height="375" />

Alternatively, you can used PDFObject package - "An open-source standards-friendly JavaScript utility for embedding PDF files into HTML documents." https://pdfobject.com/



Answered By - Matthew C
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing