Add Node JSONtoPDF example.

This commit is contained in:
Jürg Lehni 2013-11-29 12:17:59 +01:00
parent 7e65426158
commit c08fd44101
3 changed files with 38 additions and 0 deletions

18
examples/JSON/Tiger.html Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,19 @@
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.draw();
fs.writeFile(path.resolve(__dirname, 'out.pdf'), canvas.toBuffer(), function (err) {
if (err)
throw err;
console.log('Saved!');
});
});
}

1
examples/Node.js/in.json Normal file

File diff suppressed because one or more lines are too long