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

426
Vistas
Create PDF from HTML string jsPDF

I wanted to create a PDF document from the HTML string I get from SQL using jsPDF.

//HTML String (Part of)

<table style='width:100%'> <table class="test_listview" width="100%"><tr><td width="1%"></td><td width="20%";padding: 5px;  style="line-height: 20px;"><b>SG:</b></td><td width="28%";padding: 5px;  style="border-bottom: 1px solid #000;line-height: 20px;">Test</td></tr></table></table>

//Tried

var tag = document.createElement("p");
 tag.textContent = //Pasted the above HTML;
    const input = tag;
        html2canvas(input)
          .then((canvas) => {
            const imgData = canvas.toDataURL('image/png');
            const pdf = new jsPDF();
            pdf.addImage(imgData, 'JPEG', 0, 0);
            pdf.save("download.pdf");
          });

The compiler didn't work. So is there any way to make it work using jsPDf & htmlCanvas? Or any alternative to this??

Something like passing this HTML string and generating the PDF.

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