mansi shrivastava
mansi shrivastava

Reputation: 111

IONIC : pdf is not opening and downloading in IOS

I am creating pdf in IONIC 4. Following code is working on web and android but not on IOS. In IOS it is giving alert("Error creating file: " + 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';
      }

Upvotes: 0

Views: 655

Answers (1)

Sergey Rudenko
Sergey Rudenko

Reputation: 9227

See this message below. There is a bug that prevents uniform experience for local file downloads on iOS.

Two choices: 1. Upload pdf to server and redownload it. 2. Await for iOS13

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

Upvotes: 1

Related Questions