question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

html2canvas not working [multiple images on same div]

See original GitHub issue
  • You are using the latest version
  • You are testing using the non-minified version of html2canvas and checked any potential issues reported in the console

Bug reports:

<div id="scream">
  <img id="corps" class="corps" src="asset1.png"/>
  <img id="visage" class="visage" src="asset2.png"/>
  <img id="yeux" class="yeux" src="asset3.png"/>
</div>

when i select the div which includes multiple images: not working

// div select which include multiple images 
html2canvas(document.querySelector("#scream")).then(canvas => {
          document.body.appendChild(canvas)
      });
// result: dont work
// Starting DOM parsing
// Added image asset1
// Added image asset2
// Added image asset3
// Added image
// Starting renderer 
// Canvas renderer initialized (485x0 at 1542.9375,-13) with scale 0.5
// Finished rendering
 
// Nothing displayed 

when i select one image from the div: working

// single image select
html2canvas(document.querySelector("#corps")).then(canvas => {
          document.body.appendChild(canvas)
      });
// result: works
// image loaded successfully

jsfiddle: https://jsfiddle.net/tfr59Ls1/

Specifications:

  • vuejs : ^2.6.10,
  • html2canvas version tested with: 1.0.0-rc.3
  • Browser & version: chromium v73
  • Operating system: Elementary Juno

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11

github_iconTop GitHub Comments

2reactions
hakimiocommented, Jun 26, 2019

@mIcHyAmRaNe Seems to work as intended: https://jsfiddle.net/5fou1ctb/

2reactions
hakimiocommented, Jun 24, 2019

The images are just getting blocked by CORS. Set “useCORS: true” and see the errors in the console. Also, your fiddle has a bug which prevents “capture” button from working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

why is html2canvas used in a loop not getting all the images in ...
I have a page with multiple report cards in separate div tags, each with a unique id. Each report card has a student...
Read more >
I am trying to convert DIV to Image without HTML2CANVAS
I am recently trying to convert html to image in magento 1.9.2.4. so i have used Html2canvas.js. But It conflict with Magento Default ......
Read more >
Convert HTML to Image in Jquery or JavaScript [Div or Table ...
For converting HTML to Image, we need to import one more javascript library, and it is HTML2CANVAS download it and import it into...
Read more >
Features - html2canvas
Below is a list of all the supported CSS properties and values. background. background-clip (Does not support text ); background-color. background-image.
Read more >
How to run the script on the page load instead of button clicked
Overview: I have two buttons on the page (Preview, Download), the basic functionality of the preview button is to capture the div elements...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found