mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Add Node JSONtoPDF example.
This commit is contained in:
parent
7e65426158
commit
c08fd44101
3 changed files with 38 additions and 0 deletions
18
examples/JSON/Tiger.html
Normal file
18
examples/JSON/Tiger.html
Normal file
File diff suppressed because one or more lines are too long
19
examples/Node.js/JSONtoPDF.js
Normal file
19
examples/Node.js/JSONtoPDF.js
Normal 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
1
examples/Node.js/in.json
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue