Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

632
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda