Skip to content

Commit

Permalink
Minor tweaks related to #267
Browse files Browse the repository at this point in the history
  • Loading branch information
diegocr committed May 25, 2014
1 parent c8ea94b commit fac3703
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 5 additions & 3 deletions jspdf.plugin.addimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,13 @@
}
, createDataURIFromElement = function(element, format) {

//if element is an image which uses data url defintion, just return the dataurl
if (element.nodeName === 'IMG' && element.hasAttribute('src') && (''+element.getAttribute('src')).indexOf('data:image/') === 0) {
return element.getAttribute('src');
}

if(element.nodeName === 'CANVAS') {
var canvas = element;
//if element is an image which uses data url defintion, just return the dataurl
} else if (element.nodeName === 'IMG' && element.getAttribute('src') && element.getAttribute('src').indexOf('data:image/') === 0) {
return element.getAttribute('src');
} else {
var canvas = document.createElement('canvas');
canvas.width = element.clientWidth || element.width;
Expand Down
5 changes: 3 additions & 2 deletions jspdf.plugin.from_html.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,12 @@
//to support data urls in images, set width and height
//as those values are not recognized automatically
if (img.src.indexOf('data:image/') === 0) {
img.width = width || 0;
img.height = height || 0;
img.width = width || img.width || 0;
img.height = height || img.height || 0;
}
//if valid image add to known images array
if (img.width + img.height) {
//TODO: use a hash since data URIs could greatly increase the memory usage
images[url] = images[url] || img;
}
}
Expand Down

0 comments on commit fac3703

Please sign in to comment.