nodepdf 모듈.


1. phantomjs 를 다운받아 압축풀고 path 를 잡아준다.

2. app.js 의 dependencies 에 'nodepdf' : '*' 을 추가

3. index.js 에


exports.pdfcreate = function(req, res) {

var nodePDF = require('nodepdf');

var path = require('path');

var destpath = path.resove(__dirname, '..', 'uploadfolder', 'naver.pdf'); //

var pdf = new nodePDF('http://www.naver.com', destpath, {width:1024,height:760}) // 캡쳐할 사이트, 저장할 폴더 주소


pdf.on('error', function(msg) {

console.log('error', msg);

});

pdf.on('done', function(pathToFile) {

console.log('pathToFile : ', pathToFile);

res.json({result:'success'});

});


}




클라우르에 올리려면

app.js 에 추가


app.use('/uploads', express.directory(path.join(__dirname, 'uploads')));

app.use('/uploads', express.static(path.join(__dirname, 'uploads')));