Add toDataURL analog to android 2.x Browsers.
platforms: android
$ cordova plugin add com.apes.plugins.CanvasToDataURL


on Android 2.x method toDataURL() of HTML5 Canvas returns a string "data:,"

this plugin needs to resolve this problem.

How to install

cordova plugin add

or, if you using Netbeans 7.4+, then go to folder nbproject, find file, and add new line


How to use

    var canvas = getElememtById('your-canvas-id');
    var canvasData = canvas.toDataURL();
    if (canvasData === 'data:,' || canvasData.length < 10) {
        window.canvasplugin(canvas, offset, 'image/png', function(val) {
            canvasData =;

parameters for function canvasplugin(canvas, offset, type, callback) canvas - canvas html element offset - js object, which contains bounds of screen image

// includes jquery
    var offset = {
        left: $canvas.offset().left,
        top: $canvas.offset().top,
        width: $canvas.width(),
        height: $canvas.height()

this object need, when canvas element is absolute positioned, and functions canvas.offsetTop and canvas.offset returns 0.

type is mimeType of returned image, by default is 'png', allowed values is 'image/png' and 'image/jpeg'

callback - synchronous callback îf plugin