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
|
|
|
|
2016-01-26 05:41:49 -05:00
|
|
|
var canvas = paper.createCanvas(612, 792, 'pdf');
|
2013-11-29 06:17:59 -05:00
|
|
|
paper.setup(canvas);
|
|
|
|
with (paper) {
|
2014-08-16 13:24:54 -04:00
|
|
|
fs.readFile('./in.json', { encoding: 'utf8' }, function (err, data) {
|
|
|
|
if (err)
|
2016-01-26 05:41:49 -05:00
|
|
|
throw err;
|
2014-08-16 13:24:54 -04:00
|
|
|
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
|
|
|
}
|