0
我想附加BLOB PDF文件電子郵件作曲家。但它不適合我。附加PDF到電子郵件作曲家在離子
function createPdf(reportData){
return $q(function(resolve, reject) {
var dd = createDocumentDefinition(reportData);
var pdf = pdfMake.createPdf(dd)
.getBuffer(function(buffer){
var utf8 = new Uint8Array(buffer); // Convert to UTF-8...
binaryArray = utf8.buffer; // Convert to Binary...
$cordovaFile.writeFile(cordova.file.dataDirectory, "file.pdf", binaryArray, true)
.then(function (success) {
alert('Pdf created');
console.log("pdf created");
}, function (error) {
console.log("error");
});
});
});
}
此代碼的工作原理和它提醒pdf創建。
pdfGenerator.createPdf(reportbody)
.then(function(pdf){
$ionicLoading.hide();
var blob = new Blob([pdf], {type: 'application/pdf'});
$scope.pdfUrl = URL.createObjectURL(blob);
var email = {
to: '[email protected]',
cc: '[email protected]',
bcc: ['[email protected]', '[email protected]'],
attachments: [$scope.pdfUrl],
subject: 'Cordova Icons',
body: 'How are you? Nice greetings from Leipzig',
isHtml: true
};
$cordovaEmailComposer.open(email).then(null, function() {
// user cancelled email
});
},function(error){
console.log(error);
});
當我控制cordova.file.dataDirectory它給了我cdvfile://路徑不是本地路徑。那麼我如何將文件附加到郵件。