mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
e232ebc443
- Node 5 / NPM 3 struggles with it - It never worked on Windows
20 lines
653 B
JavaScript
20 lines
653 B
JavaScript
// Please note: When loading paper as a normal module installed in node_modules,
|
|
// you would use this instead:
|
|
// var paper = require('paper');
|
|
var paper = require('../../dist/paper-full.js');
|
|
var path = require('path');
|
|
var fs = require('fs');
|
|
|
|
var canvas = paper.createCanvas(612, 792, 'pdf');
|
|
paper.setup(canvas);
|
|
fs.readFile('./in.json', { encoding: 'utf8' }, function (err, data) {
|
|
if (err)
|
|
throw err;
|
|
paper.project.importJSON(data);
|
|
paper.view.update();
|
|
fs.writeFile(path.resolve(__dirname, 'out.pdf'), canvas.toBuffer(), function (err) {
|
|
if (err)
|
|
throw err;
|
|
console.log('Saved!');
|
|
});
|
|
});
|