Skip to content

Commit 044b612

Browse files
committed
clear canvas before rendering to allow jpeg export
* normally when exporting jpeg any pixel that was transparent becomes black, make them white * check for window.console.log before use (avoid crash) * html2canvas.Parse: fix missing call to html2canvas.Util.Extend for the given options
1 parent 2a3d6a0 commit 044b612

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/Core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var html2canvas = {};
1111
html2canvas.logging = true;
1212

1313
html2canvas.log = function (a) {
14-
if (html2canvas.logging) {
14+
if (html2canvas.logging && window.console && window.console.log) {
1515
window.console.log(a);
1616
}
1717
};

src/Parse.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ html2canvas.Parse = function (element, images, opts) {
4747
children,
4848
childrenLen;
4949

50+
options = html2canvas.Util.Extend(opts, options);
5051

5152
images = images || [];
5253

@@ -1254,4 +1255,4 @@ html2canvas.zContext = function(zindex) {
12541255
zindex: zindex,
12551256
children: []
12561257
};
1257-
};
1258+
};

src/Renderer.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,17 @@ html2canvas.Renderer = function(parseQueue, opts){
7878
queueLen,
7979
a,
8080
storageLen,
81-
renderItem;
81+
renderItem,
82+
fstyle;
8283

8384
canvas.width = options.width || zStack.ctx.width;
8485
canvas.height = options.height || zStack.ctx.height;
8586

86-
87+
fstyle = ctx.fillStyle;
88+
ctx.fillStyle = "#fff";
89+
ctx.fillRect(0, 0, canvas.width, canvas.height);
90+
ctx.fillStyle = fstyle;
91+
8792
for (i = 0, queueLen = queue.length; i < queueLen; i+=1){
8893

8994
storageContext = queue.splice(0, 1)[0];

0 commit comments

Comments
 (0)