export pdf

This commit is contained in:
life
2015-04-04 21:14:18 +08:00
parent 5d5e618117
commit 54720e0ae7
9 changed files with 2521 additions and 16 deletions

37
src/node_modules/api.js generated vendored
View File

@@ -668,6 +668,43 @@ var Api = {
});
},
exportPdf: function(noteId, callback) {
var me = this;
console.log(me.getUrl('note/exportPdf', {noteId: noteId}));
needle.get(me.getUrl('note/exportPdf', {noteId: noteId}), function(err, resp) {
me.checkError(err, resp);
if(err) {
return callback && callback(false);
}
// log(resp.body);
/*
{ 'accept-ranges': 'bytes',
'content-disposition': 'inline; filename="logo.png"',
'content-length': '8583',
'content-type': 'image/png',
date: 'Mon, 19 Jan 2015 15:01:47 GMT',
*/
var body = resp.body;
if(typeof body == "object" && body.Msg === false) {
return callback(false, "", body.Msg);
}
var filename = Common.uuid() + '.pdf';
var imagePath = User.getCurUserImagesPath();
var imagePathAll = imagePath + '/' + filename;
fs.writeFile(imagePathAll, resp.body, function(err) {
if(err) {
log(err);
log('local save pdf failed 本地保存失败');
callback(false);
} else {
callback(imagePathAll, filename);
}
});
});
},
// 添加标签
addTag: function(title, callback) {
var me = this;