weird caracter is displaying on jspdf (þÿ)

Viewed 935

I'm trying to write data from database on pdf using jspdf, angular 4.

when i have multiline text, a weird caracter (þÿ) is displaying on the top of every line, as describing on this capture :

enter image description here

this is my code :

var doc = new jsPDF("l", "mm", "a4");

var width = doc.internal.pageSize.getWidth();
var height = doc.internal.pageSize.getHeight();
var lMargina=2; //left margin in mm
var rMargina=2; //right margin in mm
var pdfInMM=50;  // width of A4 in mm
doc.setFontSize(11);
doc.setTextColor(255, 51, 0);   
doc.addImage(screenShot.etape1C, 'JPEG',0,0,width,height);
var qst1 =doc.splitTextToSize(res[0].libelleQuestion,(pdfInMM-lMargina- 
rMargina));
doc.text(20,60,qst1);

How can i fix this problem? I'm blocked right now with this issue.

Thank u in advance.

1 Answers

If anyone else has this issue (which I also did, unknown as to why) I resolved it by sanitizing the text to remove non-utf chars (mine was in english).

var text = "whatever my text is here"
var output = "";
for (var i=0; i<text.length; i++) {
    if (text.charCodeAt(i) <= 127) {
        output += text.charAt(i);
    }
}
text = output

This resolved it for me.

Related