paper.js/examples/Node.js/JSONtoPDF.js
Jürg Lehni 6e5d8939d5 Rename View#draw() -> View#update() and remove checkRedraw argument.
We always check for changes, since change propagation should work reliably.
2013-12-08 19:15:58 +01:00

19 lines
456 B
JavaScript

var paper = require('paper'),
path = require('path'),
fs = require('fs');
var canvas = new paper.Canvas(612, 792, 'pdf');
paper.setup(canvas);
with (paper) {
fs.readFile('./in.json', { encoding: 'utf8' }, function (err, data) {
if (err)
throw err;
project.importJSON(data);
view.update();
fs.writeFile(path.resolve(__dirname, 'out.pdf'), canvas.toBuffer(), function (err) {
if (err)
throw err;
console.log('Saved!');
});
});
}