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

132
Visualizações
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 Respostas
Responde à pergunta

0

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

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