I am using angular 2 for my projects. I have my template ready for print. I want to reuse the same for my pdf also with same css. So i wrote below code to pick up the html
parseHTML(html) {
return new DOMParser().parseFromString(html, 'text/html');
}
this._http.get('assets/print-template.html').toPromise()
.then((response: any) => {
let mynewnodes = me.parseHTML(response._body)
mynewnodes.head.innerHTML = mynewnodes.head.innerHTML + AllStyleSheets;
mynewnodes.getElementById('holder').innerHTML = printContents;
const source = mynewnodes.getElementsByTagName('html')[0].outerHTML;
});
It basically gets html from local file and makes it as a dom object and add css and dynamic content to it. I want to print the source html string that i have as a pdf. I tried jspdf but could not get it working fine.
I found below http://blog.stahlmandesign.com/export-html-to-pdf-how-hard-can-it-be/ Not sure which one to use. Basic requirement is to print static html in a variable with html and css to a pdf and export.