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

131
Vistas
dom-to-image generates only blank white image from html

I have a page that has a div element with id='cart' , and i want to be able to take screenshot of this html element. I used html2canvas and it worked fine (code is below) , but it was slow at "rendering " , so i tried dom-to-image library as it came to addresse this slow rendreing of html2canvas , i checked this library and it worked for many poeple , but for me i cant get it to work , it always generates blank white image.

Here is the code snippet i used for dom-to-image:

var cart = document.getElementById('cart')
    domtoimage.toPng(cart)
    .then(function (dataUrl) {
        var img = new Image();
        img.src = dataUrl;                               
        document.getElementById('test').appendChild(img);
    }).catch(function(error) {
        console.error('oops, something went wrong!', error);
    });

the code i used for html2canvas (working):

    $('#cart').html2canvas({
         background :'#0A4361',
         color: '#cce3ff',
         onrendered: function (newCanvas) {
            $('#test img').attr('src',newCanvas.toDataURL());
         }
    });
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I did a test on sandbox and it seems to work fine, a bit blurry though

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