paper.js/examples/Node.js/JSONtoPDF.js

20 lines
537 B
JavaScript
Raw Normal View History

2013-11-29 06:17:59 -05:00
var paper = require('paper'),
2014-08-16 13:24:54 -04:00
path = require('path'),
fs = require('fs');
2013-11-29 06:17:59 -05:00
var canvas = new paper.Canvas(612, 792, 'pdf');
paper.setup(canvas);
with (paper) {
2014-08-16 13:24:54 -04:00
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!');
});
});
2013-11-29 06:17:59 -05:00
}