jsPDF change font of the text in fromHtml method

Viewed 1064

I'm using jsPDF

is there a way how to change the default font of fromHTML. I am using fromHTML as I want to be able to copy the content of the exported PDF. The only problem is I can't change the font-family.

doc.setFont(); it's working on other method like doc.text() but not in fromHTML.

how do you guys solve this situation?

1 Answers

Personally, I've not had great luck matching the HTML fonts with the jsPDF fromHTML() method. From what I understand, this method interprets each HTML element as a PDF object, constructing images and text separately.

There is, at least by jsPDF 1.5.3, an addHTML() plugin method that utilizes html2canvas or rasterizeHTML to accomplish this by rendering into a canvas object then placing that onto the PDF document. I did have some exception with background image gradients.

If that does not help, try posting some snippets of exactly what you have.

Related