【发布时间】:2018-03-08 12:00:41
【问题描述】:
我正在使用带有 HTML2Canvas 的 jsPDF 来生成 PDF,下面是我的代码
ts:
import * as jsPDF from 'jspdf';
....
exportHTML2() {
const options = { background: '#000', };
const pdf = new jsPDF('p', 'cm', [3, 5]);
pdf.addHTML(this.content.nativeElement, options, () => {
pdf.save('Contract Details.pdf');
});
}
html:
<div class="modal-header">
<button type="button" class="close" aria-label="Close" (click)="onClose()">
<span aria-hidden="true">×</span>
</button>
<button class="btn dark btn-sm btn-outline" (click)="exportHTML2()">Export PDF</button>
<h4 class="modal-title">Contract Detail</h4>
</div>
<div class="modal-body" style="max-height: 400px;overflow: auto;">
<div class="page-container page-sidebar-closed page-content-white">
<div class="page-content">
<div #content style="background-color: white;">
<div id="content">
<!--other html elements -->
<table>
...
</table>
</div>
</div>
</div>
</div>
</div>
我正在使用 HTML2Canvas 0.4.1v 并且能够生成 pdf。但是,当 PDF 生成时,它会显示黑色背景并隐藏以下内容。
尝试在div 元素中添加背景颜色为白色,但不起作用。
任何帮助或建议都非常感谢..
【问题讨论】:
-
同样的问题怎么解决??
标签: javascript angular jspdf html2canvas