Jspdf Library Cannot Insert Utf8 Letters into Pdf

jsPDF && jsPDF AutoTable print spcial chars to PDF

Your issue is probably related to that jspdf does not support utf-8. Follow updates regarding it in this issue. The spacing issue is also mentioned there. Another good option for generating pdf files is pdfmake. It fully supports utf-8 characters.

jsPDF Corrupt PDFs?

I had similar problem, and this is how is solved it. I used Blob.js, canvas-toBlob, FileSaver. I also noticed that latest BlobBuilder.min.js is not working correcly, so I used BlobBuilder.js instead.

var content = canvas.toDataURL('image/jpeg');
var doc = new jsPDF('landscape');
doc.addImage(content, 'JPEG', 0, 0);

var data = doc.output();
var buffer = new ArrayBuffer(data.length);
var array = new Uint8Array(buffer);

for (var i = 0; i < data.length; i++) {
array[i] = data.charCodeAt(i);
}

var blob = new Blob(
[array],
{type: 'application/pdf', encoding: 'raw'}
);

saveAs(blob, filename);


Related Topics



Leave a reply



Submit