Skip to content

Commit fb99957

Browse files
committed
PDF api changes,Canvas Bug fix
1 parent 2b033fa commit fb99957

File tree

2 files changed

+38
-50
lines changed

2 files changed

+38
-50
lines changed

dist/node-i2d.js

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4999,15 +4999,6 @@ RenderImage.prototype.setAttr = function RIsetAttr(attr, value) {
49994999
if (self.image.src !== value) {
50005000
self.image.src = value;
50015001
}
5002-
} else if (
5003-
value instanceof HTMLImageElement ||
5004-
value instanceof SVGImageElement ||
5005-
value instanceof HTMLCanvasElement
5006-
) {
5007-
self.imageObj = value;
5008-
// self.postProcess();
5009-
self.attr.height = self.attr.height ? self.attr.height : value.height;
5010-
self.attr.width = self.attr.width ? self.attr.width : value.width;
50115002
} else if (value instanceof CanvasNodeExe || value instanceof RenderTexture) {
50125003
self.imageObj = value.domEl;
50135004
// self.postProcess();
@@ -6456,11 +6447,11 @@ function GetCanvasImgInstance(width, height) {
64566447
}
64576448

64586449
GetCanvasImgInstance.prototype.setAttr = function (attr, value) {
6459-
if (attr === "height") {
6460-
this.canvas.setAttribute("height", value);
6461-
} else if (attr === "width") {
6462-
this.canvas.setAttribute("width", value);
6463-
}
6450+
// if (attr === "height") {
6451+
// this.canvas.setAttribute("height", value);
6452+
// } else if (attr === "width") {
6453+
// this.canvas.setAttribute("width", value);
6454+
// }
64646455
};
64656456

64666457
function textureImageInstance(self, url) {
@@ -6568,7 +6559,8 @@ function RenderTexture(nodeExe, config) {
65686559
self.nodeExe = nodeExe;
65696560

65706561
for (var key in self.attr) {
6571-
self.setAttr(key, self.attr[key]);
6562+
if (key !== "height" && key !== "width")
6563+
{ self.setAttr(key, self.attr[key]); }
65726564
}
65736565

65746566
queueInstance.vDomChanged(nodeExe.vDomIndex);
@@ -6619,15 +6611,6 @@ RenderTexture.prototype.setAttr = function RSsetAttr(attr, value) {
66196611
if (self.image.src !== value) {
66206612
self.image.src = value;
66216613
}
6622-
} else if (
6623-
value instanceof HTMLImageElement ||
6624-
value instanceof SVGImageElement ||
6625-
value instanceof HTMLCanvasElement
6626-
) {
6627-
self.imageObj = value;
6628-
self.attr.height = self.attr.height ? self.attr.height : value.height;
6629-
self.attr.width = self.attr.width ? self.attr.width : value.width;
6630-
postProcess(self);
66316614
} else if (value instanceof CanvasNodeExe || value instanceof RenderTexture) {
66326615
self.imageObj = value.domEl;
66336616
self.attr.height = self.attr.height ? self.attr.height : value.attr.height;
@@ -6747,7 +6730,7 @@ function createPage (ctx) {
67476730
root.setSize = function (width_, height_) {
67486731
// width = width_;
67496732
// height = height_;
6750-
this.domEl = new Canvas(width_, height_, "pdf");
6733+
this.domEl = createCanvas(width_, height_, "pdf");
67516734
ctx = this.domEl.getContext("2d", config);
67526735
ctx.type_ = "pdf";
67536736
this.width = width_;
@@ -6879,6 +6862,17 @@ function pdfLayer(config, height, width) {
68796862

68806863
return this.domEl.toBuffer('application/pdf', metaData);
68816864
};
6865+
PDFCreator.prototype.exec = function (exe) {
6866+
exe.call(this, this.dataObj);
6867+
};
6868+
PDFCreator.prototype.data = function (data) {
6869+
if (!data) {
6870+
return this.dataObj;
6871+
} else {
6872+
this.dataObj = data;
6873+
}
6874+
return this;
6875+
};
68826876

68836877
return new PDFCreator(ctx);
68846878
}

src/modules/canvas.js

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -463,15 +463,6 @@ RenderImage.prototype.setAttr = function RIsetAttr(attr, value) {
463463
if (self.image.src !== value) {
464464
self.image.src = value;
465465
}
466-
} else if (
467-
value instanceof HTMLImageElement ||
468-
value instanceof SVGImageElement ||
469-
value instanceof HTMLCanvasElement
470-
) {
471-
self.imageObj = value;
472-
// self.postProcess();
473-
self.attr.height = self.attr.height ? self.attr.height : value.height;
474-
self.attr.width = self.attr.width ? self.attr.width : value.width;
475466
} else if (value instanceof CanvasNodeExe || value instanceof RenderTexture) {
476467
self.imageObj = value.domEl;
477468
// self.postProcess();
@@ -1802,11 +1793,11 @@ function GetCanvasImgInstance(width, height) {
18021793
}
18031794

18041795
GetCanvasImgInstance.prototype.setAttr = function (attr, value) {
1805-
if (attr === "height") {
1806-
this.canvas.setAttribute("height", value);
1807-
} else if (attr === "width") {
1808-
this.canvas.setAttribute("width", value);
1809-
}
1796+
// if (attr === "height") {
1797+
// this.canvas.setAttribute("height", value);
1798+
// } else if (attr === "width") {
1799+
// this.canvas.setAttribute("width", value);
1800+
// }
18101801
};
18111802

18121803
function textureImageInstance(self, url) {
@@ -1904,7 +1895,8 @@ function RenderTexture(nodeExe, config = {}) {
19041895
self.nodeExe = nodeExe;
19051896

19061897
for (const key in self.attr) {
1907-
self.setAttr(key, self.attr[key]);
1898+
if (key !== "height" && key !== "width")
1899+
self.setAttr(key, self.attr[key]);
19081900
}
19091901

19101902
queueInstance.vDomChanged(nodeExe.vDomIndex);
@@ -1955,15 +1947,6 @@ RenderTexture.prototype.setAttr = function RSsetAttr(attr, value) {
19551947
if (self.image.src !== value) {
19561948
self.image.src = value;
19571949
}
1958-
} else if (
1959-
value instanceof HTMLImageElement ||
1960-
value instanceof SVGImageElement ||
1961-
value instanceof HTMLCanvasElement
1962-
) {
1963-
self.imageObj = value;
1964-
self.attr.height = self.attr.height ? self.attr.height : value.height;
1965-
self.attr.width = self.attr.width ? self.attr.width : value.width;
1966-
postProcess(self);
19671950
} else if (value instanceof CanvasNodeExe || value instanceof RenderTexture) {
19681951
self.imageObj = value.domEl;
19691952
self.attr.height = self.attr.height ? self.attr.height : value.attr.height;
@@ -2081,7 +2064,7 @@ function createPage (ctx) {
20812064
root.setSize = function (width_, height_) {
20822065
// width = width_;
20832066
// height = height_;
2084-
this.domEl = new Canvas(width_, height_, "pdf");
2067+
this.domEl = createCanvas(width_, height_, "pdf");
20852068
ctx = this.domEl.getContext("2d", config);
20862069
ctx.type_ = "pdf";
20872070
this.width = width_;
@@ -2206,6 +2189,17 @@ function pdfLayer(config, height = 0, width = 0) {
22062189

22072190
return this.domEl.toBuffer('application/pdf', metaData);
22082191
}
2192+
PDFCreator.prototype.exec = function (exe) {
2193+
exe.call(this, this.dataObj);
2194+
}
2195+
PDFCreator.prototype.data = function (data) {
2196+
if (!data) {
2197+
return this.dataObj;
2198+
} else {
2199+
this.dataObj = data;
2200+
}
2201+
return this;
2202+
}
22092203

22102204
return new PDFCreator(ctx);
22112205
}

0 commit comments

Comments
 (0)