如何在iosPDF上使用jsPDF在Ionic 4中共享和使用SharePicker在Android / IOS设备上生成和共享PDF

问题描述 投票:0回答:1

home.html

<ion-fab vertical="bottom" horizontal="end" slot="fixed">
    <ion-fab-button (click)="sharePicker()">
      <ion-icon name="Share-alt" color="light"></ion-icon>
    </ion-fab-button>
</ion-fab>

home.ts

async sharePicker() {
var doc = new jsPDF();
var col = ["Id", "Brand name"];
var rows = [];
this.brand.forEach(element => {
  var temp = [
    element.id,
    element.name,
  ];
  console.log("temp", temp)
  rows.push(temp);

});
doc.autoTable(col, rows);
doc.save("BrandList.pdf");

this.platform.ready()
  .then(() => {
    this.socialSharing.share(null, null, doc.save("BrandList.pdf"), null)
      .then((data) => {
        console.log('Shared via SharePicker');
      }).catch((err) => {
        console.log('Was not shared via SharePicker');
      });
   });
  }

项目列表直接获取到Database并添加到col参数,

当我单击FAB按钮,然后单击PDF自动生成并打开共享选项并在社交媒体(例如whatsapp,fb等)上发送PDF时,我想要

此代码在浏览器中生成PDF,但不在设备上生成。

angular ionic-framework pdf-generation ionic4 share
1个回答
0
投票
jsPDF不会使用“ pdf.save()”在手机/平板电脑/ ipad上下载文件。
© www.soinside.com 2019 - 2024. All rights reserved.