Code to show Arabic value in pdf doesn't work. It shows me some weird language that I don't understand:
var sm = {
nature:[
{name:"nature1",ar:"الطبيعة 1"},
{name:"nature2",ar:"الطبيعة 2"},
{name:"nature3",ar:"الطبيعة 3"},
{name:"nature4",ar:"الطبيعة 4"}
],
exportateur:[
{name:"exportateur1",ar:"المصدر 1"},
{name:"exportateur2",ar:"المصدر 2"},
{name:"exportateur3",ar:"المصدر 3"},
{name:"exportateur4",ar:"المصدر 4"}
],
pays:[
{name:"germany",ar:"ألمانيا"},
{name:"france",ar:"فرنسا"},
{name:"belgium",ar:"بلجيكا"},
{name:"spain",ar:"إسبانيا"}
]
}
function createPdf(event){
"use strict";
var doc = new jsPDF();
doc.text("Nature de la marchandise: "+sm.nature[0].ar,10, 10);
doc.save("output.pdf");
}
Result :

You need to use a font that supports Arabic glyphs. And make sure it's ttf type. Amiri font is a one that works for jsPDF. Use this tool to upload the font file and it will generate a proper js file containing the base64 data of the font and jsPDF setup to add the font to its API. After that, you need to import the file into your code and set the doc font to the font you've just imported. Make sure to use the name that is set in the js file
doc.setFont("Amiri")
I got it working with this method. You need a font which shows the arabic text , I have included the base64 version of a font which shows arabic texts in this file
https://codesandbox.io/s/js-playground-forked-19t4vw?file=/src/index.js