I am using jsPDF with HTML2Canvas to generate the PDF and below is my code
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>
I am using HTML2Canvas 0.4.1v
and am able to generate the pdf. But when ever the PDF is generated its showing black background and hidding the below content.
Tried by adding background color as white in div
element but not working.
Any help or suggestions highly appreciated..