I have created JavaScript code to get data from HTML back-end and convert that HTML into the PDF.
To generate PDF, I have used JSPDF.
My HTML string looks like below:
"<p><span style="font-family:calibri;font-size:17.3333px;">Dear [@Client Name],<br></span></p><p><span style="font-family:calibri;font-size:17.3333px;">This is a sample letter that I need filled out for [@Client Name 2], who lives in [@City],[@Province]. On this date, the [@Number Date], of [@Month],[@Year]. It occurred to me that [@Client Name] was talking to [@Client Name 3].<br></span></p><p><span style="font-family:calibri;font-size:17.3333px;">The end.</span></p><p><span style="font-family:calibri;font-size:17.3333px;">Appriciate your time.<br></span></p><p><span style="font-family:calibri;font-size:17.3333px;">[@Date]</span><br></p>"
The PDF which is generated using JSPDF looks like below:
The code to generate HTML is:
function GeneratePDF(content) {
var doc = new jsPDF();
var specialElementHandlers = {
'#editor': function (element, renderer) {
return true;
}
};
doc.fromHTML(content, 15, 15, {
'width': 250,
'elementHandlers': specialElementHandlers
});
doc.save('sample-file.pdf');
}
Can you please guide me how the alignment can be managed to manage the content. Also, how can I manage the font and how to remove þÿ
character?