Html2canvas.js To change 2 code
1th Code Line 603
Window.html2canvas = function (nodelist, options) { var index = html2canvascloneindex++; options = options | | {}; if (options.logging) { window.html2canvas.logging = true; Window.html2canvas.start = date.now (); } options.async = typeof (options.async) === "undefined" ? true : options.async; options.allowtaint = typeof (options.allowtaint) === "undefined" ? false : options.allowtaint; options.removecontainer = typeof ( Options.removecontainer) === "undefined" ? true : options.removeContainer; options.javascriptenabled = typeof (options.javascriptenabled) === "undefined" ? false : Options.javascriptenabled; options.imagetimeout = typeof (options.imageTimeout ) === "undefined" ? 10000 : options.imageTimeout; Options.renderer = typeof (options.renderer) === "function" ? options.renderer : canvasrenderer; options.strict = !! options.strict; if (typeof (NodeList) === "string") { if (typeof (Options.proxy) !== "string") { return promise.reject ("Proxy must Be used when rendering url "); } var width = options.width != null ? options.width : window.innerwidth; var height = options.height != null ? options.height : window.innerheight; return Loadurldocument (Absoluteurl (nodeList), options.proxy, document, width, height, Options). Then (function (container) { return renderwindow (Container.contentwindow.document.documentelement, container, options, width, height); }); } var node = ((nodelist === undefined) ? [ document.documentelement] : ((nodelist.length) ? nodelist : [nodelist])) [0]; node.setattribute (Html2canvasnodEattribute + index, index); //return renderdocument ( node.ownerdocument, options, node.ownerdocument.defaultview.innerwidth, Node.ownerdocument.defaultview.innerheight, index). Then (function (canvas) { var width = options.width != null ? options.width : node.ownerdocument.defaultview.innerwidth; var height = options.height != null ? options.height : node.ownerDocument.defaultView.innerHeight; return renderdocument (Node.ownerdocument, options, width, height, index). Then ( function (Canvas) { if (typeof (Options.onrendered) === "function") { log (" options.onrendered is deprecated, html2canvas returns a Promise containing the canvas "); options.onrendered (Canvas); } return canvas; });};
2nd line 633
Function renderwindow (node, container, options, windowwidth, windowheight) { var clonedwindow = container.contentwindow; var support = new support (clonedwindow.document); var imageloader = new imageloader (Options, support); var bounds = GetBounds (node); var width = options.type === "View"  ? windowwidth : documentwidth (clonedwindow.document); var height = options.type === "View" ? windowheight : documentheight ( clonedwindow.document); var renderer = new options.renderer (width, height, imageloader, options, document); var parser = new nodeparser (Node, renderer, support, imageloader, options); return parser.ready.then ( function () { log ("finished rendering"); var canvas; if ( options.type === "View") { canvas = crop (renderer.canvas, {width: renderer.canvas.width, height: RENDERER.CANVAS.HEIGHT, TOP: 0, LEFT: 0, X: 0, Y: 0}); } else if (node === clonedwindow.document.body | | node === clonedwindow.document.documentelement) {// xiaomin modify canvas = renderer.canvas; } else if (Options.scale) {// xiaominzh modifyvar scale = options.scale | | 1;canvas = crop (renderer.canvas, {width: bounds.width * scale, height : bounds.height * scale, top: bounds.top *scale, left: bounds.left * Scale, x: 0, y: 0});} Else { canvas = crop ( renderer.canvas, {width: options.width != null ? options.width : bounds.width, height: options.height != null ? options.height : Bounds.height, top: bounds.top, left: bounds.left, x: clonedwindow.pagexoffset, y: clonedwindow.pageyoffset}); } cleanupcontainer (container, options); return canvas; });}
How to use
var sharecontent = $ ("#share-person-report") [0]; //required dom element of the package var width = sharecontent.offsetwidth; //Get dom width var height = sharecontent.offsetheight; //Get dom height var canvas = document.createelement ("canvas"); //Create a Canvas node var scale = 2; //define any magnification support decimal canvas.width = width * scale; //define canvas width * scale canvas.height = height * scale; //defines the canvas height * zoom canvas.getcontext ("2d"). Scale (Scale,scale); //Gets the context, sets Scalehtml2canvas ($ (' #share-person-report '), { allowtaint:true, tainttest:false, useCORS:true, background : ' #fff ', scale:scale, width:width, height:height, canvas:canvas, onrendered: function (CAV) { var src = cav.todataurl (); var html = " '; $ (' # Share-person-report '). HTML (HTML); });
Html2canvas Generate HD Images