Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
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 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!