Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

633
Views
Download PDF File inside an Iframe is not working in Chrome

I have a post web method that generate a pdf file and returns it to the client. I call to this method using a form submit in a new tab using target="_blank", so the pdf opens in the new tab using the PDF Viewer tools of Chrome. Everything is working correct with this implementation, and I can download the pdf file: introducir la descripción de la imagen aquí

But now i want to open it inside an iframe instead of a new tab. I have this in HTML:

<form id="form2" method="post" target="my_iframe" action="">
    <input type="hidden" name="wsInputs" id="wsInputs" />
</form>

<iframe style="width: 100%; height:600px" name="my_iframe" src=""></iframe>

When a button is clicked, i do this in typescript:

 const form = document.getElementById("form2") as HTMLFormElement;
 const input = document.getElementById("wsInputs") as HTMLInputElement;
 input.value = JSON.stringify(wsPDFInputs);
 form.action = endpoint + "api/v1/downloads/get-pdf";
 form.submit();

This works correct, and inside the iframe the document is opened and it works: PDF opened inside the iframe

But, when i click on download button, it does not work. This is what it happens when the file explorer is opened:

File explorer

I do not know why is this happening. In Firefox for example it is working, but not in Chrome. Also, if I click the print icon and I select "save as pdf" works too.

Any ideas? Thanks in advance.

EDIT This is the result of the request that generates the pdf: result 1

enter image description here

Maybe the problem is the response, looks like an html document instead of the pdf file, i do not know why. But the response is the same when target _blank is set.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!