小编Cla*_*ira的帖子

如何在离子2中使用pdfmake?

我正在尝试使用pdfmake在ionic2中创建pdf.

我将库添加到我的应用程序:

$ npm install pdfmake --save
Run Code Online (Sandbox Code Playgroud)

将其导入课堂

import { Component } from '@angular/core';
import { NavController, NavParams, LoadingController, ToastController, AlertController } from 'ionic-angular';

import * as pdfmake from 'pdfmake'
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试实例化并使用该方法时,设备中显示的错误:

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 …
Run Code Online (Sandbox Code Playgroud)

ionic-framework pdfmake ionic2 typescript2.0 angular

5
推荐指数
1
解决办法
2695
查看次数