小编Cra*_*ane的帖子

doc.fromHTML 不是 angular 6 的函数

我想将模板 html 导出为 pdf,我正在尝试使用带有 angular 的 jsPDF lib,但出现此错误 doc.fromHTML is not a function。

import { Component, ViewChild, ElementRef } from '@angular/core';
import * as jsPDF from 'jspdf';
// declare var jsPDF: any;
@Component({
 selector: 'app-root',
 templateUrl: './app.component.html',
 styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'exports-pdf';
@ViewChild('exports') exports: ElementRef;

public print(): void {

const doc = new jsPDF('p', 'pt', 'letter');

const content = this.exports.nativeElement;

const margins = {
  top: 80,
  bottom: 60,
  left: 40,
  width: 522
};
console.log(doc);
setTimeout(() …
Run Code Online (Sandbox Code Playgroud)

export-to-pdf jspdf angular angular6

7
推荐指数
1
解决办法
7986
查看次数

标签 统计

angular ×1

angular6 ×1

export-to-pdf ×1

jspdf ×1