├── .gitignore ├── README.md ├── index.js ├── install.sh └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This package allows you to use jsPDF on the server. Any methods that require DOM stuff will fail, but you can create and modify PDF files and save them to disk as shown in the documentation. 2 | 3 | Dependencies: 4 | ``` 5 | wget 6 | unzip 7 | ``` 8 | 9 | To use: 10 | 11 | ``` 12 | npm install 13 | ``` 14 | 15 | And then... 16 | 17 | ``` 18 | var jsPDF = require('node-jspdf'); 19 | 20 | var doc = jsPDF(); 21 | doc.text(20, 20, 'Hello, world.'); 22 | doc.save('Test.pdf', function(err){console.log('saved!');}); 23 | ``` 24 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var path = './vendor/jsPDF/'; 2 | jsPDF = require(path+'jspdf'); 3 | 4 | //Load all the plugins 5 | var plugins = ['addhtml', 'addimage', 'annotations', 'autoprint', 'cell', 'context2d', 'from_html', 'javascript', 'outline', 'png_support', 'split_text_to_size', 'standard_fonts_metrics', 'svg', 'total_pages']; 6 | plugins.map(function(plugin){ 7 | require(path+'/plugins/'+plugin+'.js'); 8 | }); 9 | 10 | //Modify the save function to save to disk 11 | var fs = require('fs'); 12 | jsPDF.API.save = function(filename, callback){ 13 | fs.writeFile(filename, this.output(), callback); 14 | } 15 | 16 | module.exports = jsPDF; 17 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | if [ ! -d vendor/jsPDF ]; then 2 | wget --no-check-certificate -O jsPDF.zip https://github.com/MrRio/jsPDF/archive/v1.2.61.zip 3 | unzip jsPDF.zip 4 | mkdir vendor 5 | mv jsPDF-* vendor/jsPDF 6 | rm jsPDF.zip 7 | fi 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-jspdf", 3 | "version": "0.0.3", 4 | "description": "Use jsPDF in your node apps.", 5 | "main": "index.js", 6 | "scripts": { 7 | "install": "sh install.sh" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "github.com/calvinfroedge/node-jspdf.git" 12 | }, 13 | "keywords": [ 14 | "jspdf", 15 | "node", 16 | "pdf" 17 | ], 18 | "author": "jspdf.com, Calvin Froedge", 19 | "license": "DBAD", 20 | "bugs": { 21 | "url": "https://github.com/calvinfroedge/node-jspdf/issues" 22 | }, 23 | "homepage": "https://github.com/calvinfroedge/node-jspdf" 24 | } 25 | --------------------------------------------------------------------------------