我正在尝试使用pdfmake在ionic2中创建PDF。
我已经将该库添加到我的应用程序中:
$ npm install pdfmake --save
将其导入到类中
import { Component } from '@angular/core';
import { NavController, NavParams, LoadingController, ToastController, AlertController } from 'ionic-angular';
import * as pdfmake from 'pdfmake'
但是,当我尝试实例化并使用该方法时,在设备上显示错误:
var dd = {
content: [
'First paragraph',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines'
],
pageSize: 'A4',
pageMargins: [25, 25, 25, 25],
};
// download the PDF
var pdf = new pdfmake();
pdf.createPdf( dd ).download();
运行时错误:
fs.readFileSync is not a function
我如何在Ionic 2中使用pdfmake?是否可能?