【问题标题】:PDF is not attached phonegap email composerPDF 未附加 phonegap 电子邮件编辑器
【发布时间】:2014-08-19 09:50:46
【问题描述】:

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

一切正常,除非我尝试附加保存到设备的 pdf 文件:当电子邮件界面打开时,我可以看到附加的 pdf(称为 test.pdf),但是当电子邮件到达收件人时,有没有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]     
        });

【问题讨论】:

    标签: ios cordova email ionic-framework


    【解决方案1】:

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

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

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

    【讨论】:

    • 好的,谢谢回复!如果我在实际设备上提醒我的路径:cdvfile://localhost/persistent/test.pdf,在模拟器上:var/mobile/Application%20Support/iPhone%20Simulator/7.1/Applications/D781404D-5C5A-4458 -ABAD-9741355D9060/Documents/test.pdf。但是,它们都不起作用。你知道为什么我在电话上收到 cdvfile:... 并且如果这是一个问题吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-14
    • 1970-01-01
    • 1970-01-01
    • 2023-03-07
    相关资源
    最近更新 更多