I was facing the same issue. In my case the Content-Type of my files was "binary/octet-stream". I had to manually change it to "application/pdf" to resolve it

Answer from Mahesh Kumar Ronde on Stack Overflow
Discussions

How to open a PDF file in an <iframe>?
Using an iframe to "render" a PDF will not work on all browsers; it depends on how the browser handles PDF files. Some browsers (such as Firefox and Chrome) have a built-in PDF rendered which allows them to display the PDF inline where as some older browsers (perhaps older versions of IE attempt to download the file instead... More on stackoverflow.com
🌐 stackoverflow.com
angular - <iframe> downloads pdf file instead of displaying - Stack Overflow
The frameSrc is coming from a parent ... the pdf instead of downloading. I did some research and found out the Content-Disposition is attachment in my browser default. How could I change this so this works on every browser? ... I don't understand why there's brackets around an attribute: [src] If you don't already know: Don't do that. More on stackoverflow.com
🌐 stackoverflow.com
November 13, 2018
How to display PDF document in an IFRAME or HTML Web ...
Hello All - Any suggestions on how to display an existing PDF document (present in notes attachment) in CRM Online (Either in an IFrame or HTML Web Resource?) · You can do this but it'll be a little bit of work. Check out these two posts: More on community.dynamics.com
🌐 community.dynamics.com
Display pdf in Web Page using iframe, embed, or object?
I've never done it, but I'd think creating an iframe and setting the src to your pdf, as you describe, would do it. This isn't a server thing, though, all you need to make sure is the content type of the link is pdf, then the browser takes it from there. More on reddit.com
🌐 r/learnprogramming
5
1
September 26, 2018
🌐
Google Groups
groups.google.com › g › flex-iframe › c › cLywT6dbe3o
PDF downloads instead of appearing in iFrame?
Hi, Please create HTML file that will embed PDF into it using following code. <embed src="test.pdf" width="100%" height="720"></embed> And call that HTML file using iFrame. I think this will help you.
🌐
Nutrient
nutrient.io › blog › sdk › how to embed a pdf viewer in your website
How to embed a PDF viewer in a website: Six methods (2026 guide)
March 23, 2026 - Add #toolbar=0 to your iframe src attribute (<iframe src="document.pdf#toolbar=0">) to hide Chrome’s toolbar. However, this is easily bypassed and only works in Chrome’s built-in viewer.
🌐
Cloudpdf
cloudpdf.io › blog › how-to-embed-a-pdf-in-html-without-the-ability-to-download
How to embed a PDF in HTML without the ability to download
Additionally, Google Drive does not provide any options to customize the PDF viewer to fit with your design. This solution may not be ideal for you if you want to customize the viewer or limit who can view documents, for example providing access only to specific users inside your application. If this is the case, you can scroll up to the previous solution. If this solution is sufficient for you, you can follow the steps below. ... Great job, now you are almost done. You now can embed this document inside an <iframe> on your website.
Find elsewhere
🌐
Mozilla Bugzilla
bugzilla.mozilla.org › show_bug.cgi
1662216 - PDF iframe embeds prompt for download instead of displaying in-page
The PDF should have been embedded in the iframe without getting an automatic download prompt. ... Summary: PDF embeds prompt for download instead of displaying in-page → PDF iframe embeds prompt for download instead of displaying in-page
🌐
Medium
medium.com › @kolgate1001 › how-to-display-a-pdf-file-without-allowing-people-to-download-or-save-it-in-angular-da470c836865
How to display a PDF file without allowing people to download or save it in Angular | by Phung Toan | Medium
November 21, 2021 - The way to use ng2-pdf-viewer is similar to using iframe/embed (which I mentioned earlier) but instead of using <iframe> or <embed> tag, we will use <pdf-viewer> Now you can display the content of the PDF file yourself.
Top answer
1 of 3
1
  • I don't understand why there's brackets around an attribute: [src] If you don't already know: Don't do that.

  • <iframe> doesn't have type as a valid attribute, but type does work for <iframe>'s sister tags <object> and <embed>.

The following Demo does not function on SO due to their restrictive sandbox. Go to this Plunker to see a functional Demo. Source PDF courtesy of PDFObject


Plunker --- Demo ====

It looks like Plunker no longer runs embeded content anymore, so if you want to review a functioning demo, simply copy and paste the entire code in any text editor (Notepad, Notepad++, etc.) and save as an HTML file (.html file extension).


<!DOCTYPE html>
<html>

<head>
  <style>
    * {
      margin: 0;
      padding: 0;
    }
    
    figure {
      display: table;
      border: 3px ridge grey;
      position: relative;
      width: 96vw;
      min-height: 250px;
      height: auto;
      margin: 0 auto 35px;
    }
    
    figcaption {
      border: 3px ridge grey;
      text-align: center;
      font: 900 20px/1.5 Verdana;
      padding: 0 0 8px 0;
      background: rgba(51, 51, 51, 0.3);
      color: #fff;
    }
    
    iframe,
    object,
    embed {
      overflow: hidden;
      position: absolute;
    }
  </style>
</head>

<body>

  <figure>
    <figcaption>IFRAME</figcaption>
    <iframe src="https://pdfobject.com/pdf/sample-3pp.pdf#page=1" class="frameSet" frameborder="0" allowfullscreen width="100%" height="100%"></iframe>
  </figure>

  <figure>
    <figcaption>OBJECT</figcaption>
    <object data="https://pdfobject.com/pdf/sample-3pp.pdf#page=2" class="objectSet" type="application/pdf" width="100%" height="100%"></object>
  </figure>

  <figure>
    <figcaption>EMBED</figcaption>
    <embed src="https://pdfobject.com/pdf/sample-3pp.pdf#page=3" class="embedSet" type="application/pdf" width="100%" height="100%">
  </figure>

</body>


</html>

2 of 3
1

You need to modify your URL like the below

iframeURL =  'urlThatYouGetFromAPI' + '&embedded=true'
<iframe [src]="iframeURL"></iframe>

Actually, All you need is adding this string &embedded=true to the end of URL.

Also you can use domSanatizer to make it more safe

 readonly #domSanitizer = inject(DomSanitizer);
 iframeURL = this.#domSanitizer.bypassSecurityTrustResourceUrl(
                `${URL}&embedded=true`
            );
🌐
Dynamics Community
community.dynamics.com › forums › thread › details
How to display PDF document in an IFRAME or HTML Web ...
Hello All - Any suggestions on how to display an existing PDF document (present in notes attachment) in CRM Online (Either in an IFrame or HTML Web Resource?) · You can do this but it'll be a little bit of work. Check out these two posts:
🌐
Quora
quora.com › How-do-I-embed-a-PDF-file-in-HTML-without-a-download-save-and-print-option
How to embed a PDF file in HTML without a download, save and print option - Quora
Answer (1 of 3): “There is a cloud based PDF viewer available from CloudPDF. This is probably the surest way to prevent your visitors from downloading a document as it stores the PDF in the cloud instead of locally on your browser.
🌐
DEV Community
dev.to › asifroyal › displaying-pdf-files-in-an-iframe-a-simple-solution-2anj
Displaying PDF Files in an Iframe: A Simple Solution - DEV Community
December 21, 2022 - This function takes a URL as an argument and uses cURL to download the content of the PDF file at that URL. The content is then returned as a string. Next, we can use the base64_encode function to encode the PDF data as a base64 string, which we can then use as the src attribute for an iframe element:
🌐
W3Docs
w3docs.com › html
How to Embed PDF in HTML
Learn how to embed PDF documents in HTML using the a and iframes tags, and make PDF files not downloadable with W3Docs. Practice with examples
🌐
egghead.io
egghead.io › tips › embed-pdfs-in-html-with-embed-iframe-and-object-tags
Embed PDFs in HTML with embed, iframe, and object tags
01:08 download the PDF and then do a href tag. Then if the PDF is not found, we will get our normal iframe. It cannot find something. This message will only be rendered if the iframe tag itself is not · 01:24 supported.
🌐
Reddit
reddit.com › r/learnprogramming › display pdf in web page using iframe, embed, or object?
r/learnprogramming on Reddit: Display pdf in Web Page using iframe, embed, or object?
September 26, 2018 -

I'm trying to display a PDF in my web page but not have it open a new page. I've been looking at embed, iframe, and object tags and have seen their pros and cons and I'm more or less pushing for iframe. I select the file from a treeview that gets the files from a REST API and I want to add the selected file to the src of the iframe but don't know exactly how to do it. I was able to make it so the file opens to its own page but not sure about embedding it. Any advice?

Here's my code to display the file in its own page. filePath is the full path for the file and selectFile is just the file name itself.

 Dim user As WebClient = New WebClient()
        Dim buffer As Byte() = user.DownloadData(filePath)
        If Not buffer Is Nothing Then
            Response.AddHeader("content-length", buffer.Length.ToString())
            Response.AddHeader("Content-Disposition", "inline; filename=" + selectFile)
            Response.ContentType = "application/pdf"
            Response.BinaryWrite(buffer)
        End If

🌐
Vivaldi
forum.vivaldi.net › topic › 49170 › displaying-a-pdf-file-in-an-iframe-springboot
Displaying a pdf file in an iframe (springboot) | Vivaldi Forum
September 22, 2022 - <html> <body> <script type="text/javascript"> var pdfFile = "http://jkorpela.fi/latin9.pdf"; </script> <iframe src="https://research.google.com/pubs/archive/44678.pdf" width="1000" height="500" id="ifr2"> </iframe> <p> <a href="#" onClick='document.getElementById("ifr2").src=`${pdfFile}`;'>Click to change PDF!</a> </p> </body> </html> Take note of the backticks around ${pdfFile}.
🌐
OpenReplay
blog.openreplay.com › step-by-step--embedding-pdfs-in-html-pages
Step by step: embedding PDFs in HTML pages
Improved user experience: Users ... we’ll show three ways of embedding PDF files in your HTML pages: Method 1: Using <iframe> tag....
🌐
Reddit
reddit.com › r/firefox › iframe pdfs keeps asking me to save
r/firefox on Reddit: Iframe PDFs keeps asking me to save
December 11, 2020 -

Hi all,

I'm a Firefox user for as long as Firefox and Mozilla exists 😁

I never switched to any other browser no matter what happened. But I do try other and have them installed as I'm web developer so testing in other browsers is a must.

What I have a problem for quite some time is that iframe with PDF doesn't work as intended in many web apps for me. I've also tried to code it my self but can't make it work.

Firefox immediately ask to download the PDF or view in in new tab (recently added), but all other browsers allows embedding PDFs.

Is it a known issue/feature or?

Thanka

🌐
Brave Community
community.brave.com › browser support › desktop support
Javascript PDF iframe Links Don't Download When "Download PDF files instead of automatically opening them in Brave" is Checked - Desktop Support - Brave Community
August 21, 2019 - I’m having an issue where javascript links pointing to a PDF in an iframe don’t display and won’t download like they used to a few months ago. “Download PDF files instead of automatically opening them in Brave” is checked in Site Settings. The iframe type is “application/pdf” and ...