mirror of
https://github.com/leanote/desktop-app.git
synced 2026-01-28 02:00:56 +08:00
export pdf
This commit is contained in:
37
src/node_modules/api.js
generated
vendored
37
src/node_modules/api.js
generated
vendored
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user