Html2canvas: How can I set the background colour to transparent?

Created on 12 Jul 2017  ·  6Comments  ·  Source: niklasvh/html2canvas

After setting the background in options to #ffffff, the colour of my canvas is white, it is okay, but the remaining area other than canvas image is transparent, how can I set that remaining area also to a colour e.g a white colour?

Bug

Most helpful comment

html2canvas(canvasDom, { allowTaint: true, useCORS: true, backgroundColor: "rgba(0,0,0,0)", removeContainer: true, x: 0, y: 0, width: 374, height: 722 })

All 6 comments

You can set backgroundColor to null to make it transparent or any color to make the canvas render with the background color

Here, changing the backgroundColor option has effect, but changing it to null creates a black background in the canvas, while there's no black background in my CSS.

I am also getting the canvas render a black background when setting backgroundColor to null

html2canvas(canvasDom, { allowTaint: true, useCORS: true, backgroundColor: "rgba(0,0,0,0)", removeContainer: true, x: 0, y: 0, width: 374, height: 722 })

allowTaint: true with backgroundColor: "rgba(0,0,0,0)" Solved the problem

I don't think allowTaint helps in any way with this issue. For me
backgroundColor: 'rgba(0, 0, 0, 0)', removeContainer: true,
settings were the ones needed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stevencherry1 picture stevencherry1  ·  3Comments

anthonymejia picture anthonymejia  ·  4Comments

kunal886496 picture kunal886496  ·  3Comments

arzyu picture arzyu  ·  3Comments

wbarrantes picture wbarrantes  ·  3Comments