From 8d965029daa3d143f2147841a4818b17a93cedac Mon Sep 17 00:00:00 2001 From: Paolo Date: Tue, 17 Apr 2012 10:57:25 +0200 Subject: [PATCH] Fixed support for other Renderers other than Canvas --- build.xml | 2 ++ src/Renderer.js | 4 ++-- src/Util.js | 18 ++++++++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/build.xml b/build.xml index 9376385..a0e5da7 100644 --- a/build.xml +++ b/build.xml @@ -23,6 +23,7 @@ + @@ -76,6 +77,7 @@ + diff --git a/src/Renderer.js b/src/Renderer.js index 3513391..834767e 100644 --- a/src/Renderer.js +++ b/src/Renderer.js @@ -58,9 +58,9 @@ _html2canvas.Renderer = function(parseQueue, options){ sortZ(parseQueue.zIndex); - if ( typeof options.renderer._create !== "function" ) { + if ( typeof options._renderer._create !== "function" ) { throw new Error("Invalid renderer defined"); } - return options.renderer._create( parseQueue, options, document, queue, _html2canvas ); + return options._renderer._create( parseQueue, options, document, queue, _html2canvas ); }; diff --git a/src/Util.js b/src/Util.js index 9934691..ddd394d 100644 --- a/src/Util.js +++ b/src/Util.js @@ -34,14 +34,20 @@ html2canvas = function( elements, opts ) { flashcanvas: undefined, // path to flashcanvas width: null, height: null, - taintTest: true // do a taint test with all images before applying to canvas - - }; + taintTest: true, // do a taint test with all images before applying to canvas + renderer: "Canvas" + }, renderer; options = _html2canvas.Util.Extend(opts, options); - - options.renderer = options.renderer || _html2canvas.Renderer.Canvas( options ); - + + if (typeof options.renderer === "string" && _html2canvas.Renderer[options.renderer] !== undefined) { + options._renderer = _html2canvas.Renderer[options.renderer]( options ); + } else if (typeof options.renderer === "function") { + options._renderer = _html2canvas.Renderer.Canvas( options ); + } else { + throw("Unknown renderer"); + } + _html2canvas.logging = options.logging; options.complete = function( images ) {