After my user fills out the form I want to render the page to PDF.
There are a lot of options for HTML to PDF, how would I render the page in memory and get the innerHtml? Or is there another way?
Right now I'm building the PDF manually.
After my user fills out the form I want to render the page to PDF.
There are a lot of options for HTML to PDF, how would I render the page in memory and get the innerHtml? Or is there another way?
Right now I'm building the PDF manually.
Try to use jspdf and html2canvas
install this package.
npm i jspdf
npm i html2canvas
ts file
import * as jsPDF from 'jspdf';
import h2c from 'html2canvas';
loadPDF() {
let doc = new jsPDF('p', 'pt', 'a4');
h2c(document.getElementById('pagePrintPdf')).then(function (canvas) {
let width = doc.internal.pageSize.getWidth();
let height = doc.internal.pageSize.getHeight();
let dataURL = canvas.toDataURL('image/jpeg', 1.0);
doc.addImage(dataURL, 'jpg', 0, 0, width, height, 'none');
doc.save(`test.pdf`);
});
}