• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

268
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 3 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 3 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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda