Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Minor tweaks related to #267

  • Loading branch information...
commit fac37034762120e0815dd3ae9c5abd4f4efe6e50 1 parent c8ea94b
@diegocr diegocr authored
Showing with 8 additions and 5 deletions.
  1. +5 −3 jspdf.plugin.addimage.js
  2. +3 −2 jspdf.plugin.from_html.js
View
8 jspdf.plugin.addimage.js
@@ -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;
View
5 jspdf.plugin.from_html.js
@@ -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;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.