Options for node-canvas

Allowing to write pdf via node-canvas
```var canvas = fabric.createCanvasForNode(200, 200,'pdf');
..
fs.writeFile('out.pdf', canvas.nodeCanvas.toBuffer());```
This commit is contained in:
RG72 2014-02-09 12:42:15 +05:00
parent c664de7052
commit 107dd5735f

View file

@ -137,12 +137,14 @@
* @param width Canvas width
* @param height Canvas height
* @param {Object} options to pass to FabricCanvas.
* @param {Object} options to pass to NodeCanvas.
* @return {Object} wrapped canvas instance
*/
fabric.createCanvasForNode = function(width, height, options) {
fabric.createCanvasForNode = function(width, height, options, nodeCanvasOptions) {
nodeCanvasOptions = nodeCanvasOptions || options;
var canvasEl = fabric.document.createElement('canvas'),
nodeCanvas = new Canvas(width || 600, height || 600);
nodeCanvas = new Canvas(width || 600, height || 600, nodeCanvasOptions);
// jsdom doesn't create style on canvas element, so here be temp. workaround
canvasEl.style = { };