2015-04-19 117 views

回答

1

我能夠做到這一點與jsPDFcordova email composer插件。這對我來說很適合創建小型PDF文件,但大型文件存在一些問題(我可能做錯了什麼)。

這裏是我的代碼示例:

var doc = new jsPDF('p', 'pt', 'letter'); 
doc.addHTML(window.document.body, function() {  
    var filename = 'report.pdf'; 
    var dataUrl = doc.output('dataurlstring'); 

    // This part is only required because the dataurl formats from the 2 plugins don't match up (see Note at the bottom of my post) 
    var base64parts = dataUrl.split(','); 
    base64parts[0] = "base64:" + window.escape(filename) + "//"; 
    var compatibleAttachment = base64parts.join(""); 

    window.plugin.email.open({ 
     subject: 'Report', 
     body: 'Report is attached', 
     attachments: [compatibleAttachment] 
    }); 
}); 

*注:與在科爾多瓦電子郵件作曲家插件(0.8.2)的最新版本發送附件中的錯誤,但我能得到它在這個link的幫助下使用0.8.1工作。

+0

有關addHtml()的更多信息,請查看https://github.com/MrRio/jsPDF/blob/cb8129e595dd5b9bc59b450d57c1108c21b10e9e/plugins/addhtml.js。 –

相關問題