PDF Test

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

PDF MAker

Install JSPDF
npm install jspdf --save

Install Typing for PDF


npm install @types/jspdf --save-dev

In html

<div id="content" #content>


<p>Content</p>
</div>

<button (click)="downloadPDF()">Download PDF</button>

In TS

import ElementRef, ViewChild;


Import * as jsPDF from 'jspdf';

ViewChild ('content') content :ElementRef;


download PDF()

{
let doc=new jsPDF();
let specialElemHandler ={
'#editor': function(element,, renderer){
return true;
}

};
let content=this.content.nativeElement;
doc.fromHTML(content.innerHTML, 15,15
{
'width':190,
'elementHandler':specialElementHandlers
});

doc.save('test.pdf');
}

Method 2
----------

Install jspdf

install typings

In HTML

<button (click)="downloadPDF()">PDF</button>
IN TS
import jspdf
downloadPDF()
{
const doc=new jsPDF();
doc.text('some text here',10,10) ;
doc.save('test.pdf');
}

You might also like