2016-01-29 17:06:31 -05:00
|
|
|
// Please note: When loading paper as a normal module installed in node_modules,
|
|
|
|
// you would use this instead:
|
2017-04-19 14:32:12 -04:00
|
|
|
// var paper = require('paper-jsdom-canvas');
|
2016-02-15 17:59:31 -05:00
|
|
|
var paper = require('../../dist/paper-core.js');
|
2016-01-29 17:06:31 -05:00
|
|
|
var path = require('path');
|
|
|
|
var 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);
|
2016-01-27 03:34:37 -05:00
|
|
|
fs.readFile('./in.json', { encoding: 'utf8' }, function (err, data) {
|
|
|
|
if (err)
|
|
|
|
throw err;
|
|
|
|
paper.project.importJSON(data);
|
|
|
|
paper.view.update();
|
2016-02-15 17:59:31 -05:00
|
|
|
fs.writeFile(path.resolve('./out.pdf'), canvas.toBuffer(), function (err) {
|
2014-08-16 13:24:54 -04:00
|
|
|
if (err)
|
2016-01-26 05:41:49 -05:00
|
|
|
throw err;
|
2016-01-27 03:34:37 -05:00
|
|
|
console.log('Saved!');
|
2014-08-16 13:24:54 -04:00
|
|
|
});
|
2016-01-27 03:34:37 -05:00
|
|
|
});
|