• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

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

[复制链接]
菜鸟教程小白 发表于 2022-12-13 00:48:34 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我正在使用以下插件从 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 ,我也尝试删除路径开始(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:      ['[email protected]'],
            subject: 'Congratulations',
            body:    '<h1>Happy Birthday!!!</h1>',
            attachments: [file]     
        });



Best Answer-推荐答案


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

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

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

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

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap