PDF没有附加phonegap电子邮件作曲家

时间:2014-08-19 09:50:46

标签: ios cordova email-integration ionic-framework

我使用以下插件从iphone phongeap app发送电子邮件(使用离子):https://github.com/katzer/cordova-plugin-email-composer

除非我尝试附加保存到设备的pdf文件,否则一切正常:当电子邮件界面打开时,我可以看到附加的pdf(称为test.pdf),但当电子邮件到达收件人时,那里& #39; s没有PDF。取而代之的是附加的txt文件,但没有任何内容。

如果我转到window.replace(pdf的路径),PDF会打开,所以我确定PDF已保存并且路径正确。在阅读了这个https://github.com/katzer/cordova-plugin-email-composer/issues/33之后,我还试图取消路径start(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]     
        });

1 个答案:

答案 0 :(得分:1)

我们正在使用完全相同的插件并使其正常工作,我们使用的URL看起来像这样

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

网址从我们使用的pdf插件返回到我们的应用程序。

相关问题