magic4
This commit is contained in:
20
static/Magic4/paperjs-v0.12.15/examples/Node.js/JSONtoPDF.js
Normal file
20
static/Magic4/paperjs-v0.12.15/examples/Node.js/JSONtoPDF.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// Please note: When loading paper as a normal module installed in node_modules,
|
||||
// you would use this instead:
|
||||
// var paper = require('paper-jsdom-canvas');
|
||||
var paper = require('../../dist/paper-core.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('./out.pdf'), canvas.toBuffer(), function (err) {
|
||||
if (err)
|
||||
throw err;
|
||||
console.log('Saved!');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user