Last active
August 29, 2015 14:07
-
-
Save maggocnx/a02eff4d69cdacd12421 to your computer and use it in GitHub Desktop.
Print
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
isNodeWebkit = (typeof process !== "undefined") ; | |
$("body").append('<canvas id="printCanvas" width="384" height="'+ canvasHeight + '"></canvas>'); | |
var canvas = document.getElementById('printCanvas'); | |
this.drawCanvas(canvas,order, function(){ | |
if(isNodeWebkit){ | |
fs = require("fs"); | |
var exec = require("child_process").exec; | |
var __dirname = process.cwd(); | |
var imgData = canvas.toDataURL().replace(/^data:image\/\w+;base64,/, ""); | |
var buf = new Buffer(imgData, 'base64'); | |
var imgPath =__dirname + "/tmp.png"; | |
fs.writeFile(imgPath , buf, function(err){ | |
// exec("convert tmp.png -flatten -negate -monochrome -colors 2 print.bmp", function(){ | |
exec("convert tmp.png -flip -flatten -negate -monochrome -colors 2 bmp:- | tail -c+35 > /dev/thprint", function(){ | |
$ionicLoading.hide(); | |
}); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment