【问题标题】:IONIC : pdf is not opening and downloading in IOSIONIC:pdf没有在IOS中打开和下载
【发布时间】:2019-07-18 06:29:46
【问题描述】:

我正在 IONIC 4 中创建 pdf。以下代码适用于 web 和 android,但不适用于 IOS。在 IOS 中它发出警报(“创建文件时出错:” + err);

  .catch(err => {
              this.runloading = 'hide';
              alert("Error creating file: " + err);
              throw err;
            });
if (this.platform.is("cordova")) {
        this.pdfObj.getBuffer(buffer => {
          var blob = new Blob([buffer], { type: "application/pdf" });
          this.file
            .writeFile(this.file.externalRootDirectory, "pro.pdf", blob, {
              replace: true
            })
            .then(fileEntry => {
              this.fileOpener
                .open(
                  this.file.externalRootDirectory + "pro.pdf",
                  "application/pdf"
                )
                .catch(err => alert("Please install pdf viewer"));
              this.runloading = 'hide';

            })
            .catch(err => {
              this.runloading = 'hide';
              alert("Error creating file: " + err);
              throw err;
            });
        });
      } else {
        pdfmake.createPdf(docDefinition).open();
        // this.pdfObj.download();
        this.runloading = 'hide';
      }

【问题讨论】:

    标签: pdf ionic-framework pdfmake


    【解决方案1】:

    请参阅下面的此消息。有一个错误会阻止 iOS 上本地文件下载的统一体验。

    两种选择: 1.上传pdf到服务器并重新下载。 2.等待iOS13

    https://github.com/eligrey/FileSaver.js/issues/375#issuecomment-460318259

    【讨论】:

      猜你喜欢
      • 2021-04-23
      • 2011-01-27
      • 2017-10-16
      • 2023-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多