angular - 如何在 Angular 10 中将动态表导出为 PDF
问题描述
我想使用我现有的动态表制作一个 PDF 文件。我已经尝试过,结果将是 50% 成功。我使用jsPDF,结果就像。我也想更改列宽和标题文本...
组件.HTML
id="htmlData" #htmlData
我在我的容器 div 中使用它
组件.TS
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import * as jsPDF from 'jspdf'
@ViewChild('htmlData') htmlData: ElementRef;
public openPDF():void {
let DATA = this.htmlData.nativeElement;
let doc = new jsPDF('l','pt', 'a4');
doc.fromHTML(DATA.innerHTML,15,15,{
'width':400,
// autoSize:true,
});
doc.output('dataurlnewwindow');
}
解决方案
使用jsPDF-AutoTable - jsPDF npm的表格插件
推荐阅读
- visual-studio - 如果需要构建项目,如何更改 Visual Studio 的检查
- php - LARAVEL我如何提交表单,在url中保持现有查询字符串不变
- regex - 正则表达式:如何创建一个模式以匹配至少一个小写字符、大写字符、数字和至少一个 [$@#&!] 之间的字符
- google-chrome - Chrome在线PDF计算失败
- javascript - React Google Maps:在 MapWithADirectionRenderer 上显示标记重组组件
- git - 使用名称、状态和提交 sha 获取差异
- angular - 在角度库中使用外部库会导致错误
- javascript - 使每次调用返回的匿名函数成为相同的实例
- docker - 无法从 NiFi 发送到 Kafka
- r - 用 R 中的最大行替换 nan 值