Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

329
Vistas
How do I prevent HTML2PDF from auto-downloading the pdf?

I have a HTML2PDF method in my JavaScript code. The code is working great on one hand as I can open the rendered pdf in a new blob tab and open the print window. However, as I do that, the pdf automatically downloads as well. I wish to prevent the method from downloading the .pdf file and only open the print window in the new tab. The following code is what I have. Any help would be greatly appreciated!

    html2pdf(body, {
      filename: 'test.pdf',
      jsPDF: {
          orientation: 'portrait',
        }
    })
      .from('element-to-print')
      .get('pdf')
      .then(function (pdfObj) {
        pdfObj.autoPrint();
        window.open(pdfObj.output('bloburl'), 'F');
      });

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Try this code :

html2pdf() // move your config in the .set({...}) function below
  .set({
    filename: 'test.pdf',
    jsPDF: {
      orientation: 'portrait',
    }
  })
  .from('element-to-print')
  .outputPdf()  // add this to replace implicite .save() method, which triggers file download
  .get('pdf')
  .then(function (pdfObj) {
    pdfObj.autoPrint();
    window.open(pdfObj.output("bloburl"), "F")
  });
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda