I have been searching for hours to enable the UTF-8 support in jsPDF library, since it is a new feature released in jsPDF 1.4 I can't find useful resources to enable it
I found two methods in the library addFont()
& setFont()
but it is not clear in the official docs how to use them to use the new font & if they depend on each other
I am specifically trying to add a font that supports Arabic, like for example (Roboto) or any basic font that support Arabic
The code that I am using (& works well with English html but not Arabic):
printAsPDF() {
const elementToPrint = document.getElementById('report'); // The html element to become a pdf
const pdf = new jsPDF();
pdf.setFont('Helvetica');
console.log(pdf.getFontList());
pdf.fromHTML(elementToPrint, 30, 30);
pdf.save('hello.pdf');
}
The fonts that are supported by default:(output of getFontList()
):
Courier
Helvetica
Symbol
Times
ZapfDingbats
courier
helvetica
symbol
times
zapfdingbats