オプションで背景を#ffffffに設定した後、キャンバスの色は白で問題ありませんが、キャンバス画像以外の残りの領域は透明です。残りの領域も色(たとえば白色)に設定するにはどうすればよいですか?
backgroundColor
をnull
に設定して透明にするか、任意の色を設定してキャンバスを背景色でレンダリングすることができます
ここでは、backgroundColorオプションを変更すると効果がありますが、nullに変更すると、キャンバスに黒い背景が作成され、CSSには黒い背景がありません。
backgroundColorを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
とbackgroundColor: "rgba(0,0,0,0)"
問題を解決しました
allowTaint
がこの問題に役立つとは思いません。 私のために
backgroundColor: 'rgba(0, 0, 0, 0)',
removeContainer: true,
設定は必要なものでした。
最も参考になるコメント
html2canvas(canvasDom, { allowTaint: true, useCORS: true, backgroundColor: "rgba(0,0,0,0)", removeContainer: true, x: 0, y: 0, width: 374, height: 722 })