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

116
Visualizações
Downloading a pdf without opening new tab or changing current tab view

I have a pdf I am receiving from an api call and I want to accomplish downloading the file to my computer without it opening a new tab or opening the url in the current tab I have open. I realize this is a question frequently asked but all I can find are examples accomplishing the opening new tab or loading in the current tab.

Ive tried using an tag like:

         <Button
              className="save-sign-note"
            >
              <a href={pdfURL} download={`${props.visitType}`}>
              Download and Next <RightArrow /> 
              </a>
            </Button>

and this downloads the file in the current window.

Also Ive tried using a handler like:

<Button
onClick={() => DowloadAndNext()}
>...

const DowloadAndNext = () => {
     window.location.href = pdfURL;
  };

and

<Button
onClick={() => DowloadAndNext()}
>...

const DowloadAndNext = () => {
    const url = pdfURL;
    const link = document.createElement("a");
    link.href = url;
    link.setAttribute("download", "file.pdf");
    document.body.appendChild(link);
    link.click();
  };

but I get the same result each time. Any help with this would be awesome as I am new to developing front end.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can’t control this from your website for pdf downloads. This is a browser settings behavior when downloading PDFs. Changing the default pdf software to Adobe reader instead of edge may solve this.

about 4 years ago · Juan Pablo Isaza Relatório
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