From 107dd5735f7074ecf426d1280bb28161e8d97c86 Mon Sep 17 00:00:00 2001 From: RG72 Date: Sun, 9 Feb 2014 12:42:15 +0500 Subject: [PATCH] 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());``` --- src/node.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/node.js b/src/node.js index 4b8071db..8b03b850 100644 --- a/src/node.js +++ b/src/node.js @@ -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 = { };