ios - PDF 未附加 phonegap 电子邮件编辑器

标签 ios cordova email ionic-framework

我正在使用以下插件从 iphone phongeap 应用程序(使用 ionic)发送电子邮件:https://github.com/katzer/cordova-plugin-email-composer

一切正常,除了当我尝试附加保存到设备的 pdf 文件时:当电子邮件界面打开时,我可以看到附加的 pdf(称为 test.pdf),但是当电子邮件到达收件人时,有没有PDF。相反,有一个附加的 txt 文件,但没有任何内容。

如果我转到 window.replace(path to pdf),PDF 会打开,所以我确定 PDF 已保存且路径正确。看完这篇,https://github.com/katzer/cordova-plugin-email-composer/issues/33 ,我也曾尝试删除路径开始 (file://) 并将其替换为 (relative://) 但没有用。非常感谢对此的任何输入:这是相关代码:

    var doc = new jsPDF();

    doc.text(20, 20, 'HELLO!');

    doc.setFont("courier");
    doc.setFontType("normal");
    doc.text(20, 30, 'This is a PDF document generated using JSPDF.');
    doc.text(20, 50, 'YES, Inside of PhoneGap!');

    var pdfOutput = doc.output();
    console.log( pdfOutput );


window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {



  fileSystem.root.getFile("test.pdf", {create: true}, function(entry) {
  var fileEntry = entry;
  console.log(entry);

  $scope.filepath =  fileEntry.toURL();

  $scope.filepath = $scope.filepath.replace('file\:\/\/', 'relative://');




    $scope.emailer($scope.filepath);    


     //  window.location.href = $scope.filepath;




  entry.createWriter(function(writer) {
     writer.onwrite = function(evt) {
     console.log("write success");
  };

  console.log("writing to file");
     writer.write( pdfOutput );
  }, function(error) {
     console.log(error);
  });

  }, function(error){
   console.log(error);
 });





},
function(event){
 console.log( evt.target.error.code );
 });



    $scope.emailer = function(file) {


    alert(file);



    window.plugin.email.open({
            to:      ['info@appplant.de'],
            subject: 'Congratulations',
            body:    '<h1>Happy Birthday!!!</h1>',
            attachments: [file]     
        });

最佳答案

我们正在使用完全相同的插件并使其正常工作,我们使用的 URL 如下所示

/var/mobile/Applications/998AEF02-5D26-4064-BC7D-A94A218609C5/Documents/yourpdffilenamehere.pdf

URL 从我们使用的 pdf 插件返回到我们的应用。

关于ios - PDF 未附加 phonegap 电子邮件编辑器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25380401/

相关文章:

ios - 当用户更改位置时如何使 map 居中

ios - 从另一个类访问 UIButton 不起作用?

android - 确保安装时使用的Node.js版本与运行时使用的版本匹配

ruby-on-rails - Rails 3.0 发送邮件安全最佳实践

电子邮件签名中的 HTML 调整图像

ios - Storyboard中多个 View Controller 使用的公共(public) View

ios - "Type' 程序 ' does not conform to protocol ' 任何对象 '"

javascript - 如何设计一个 Web 应用程序以允许多个存储提供商?

android - Ionic Music Controls 不工作 | Ionic 3 + Ionic Native Media + Ionic Native 音乐控制

mysql长查询在完成之前通过电子邮件发送