Missing characters when rendering an arabic text
Hey,
As the title says, I have Cairo-Regular-normal.js file contains:
export const Cairo = 'AAEAAAARAQAABA.....';
And Card.js file contians:
<script>
import * as jsPDF from 'jspdf';
import html2canvas from 'html2canvas';
import { Cairo } from '@/assets/fonts/Cairo-Regular-normal.js';
export default {
methods: {
download(student) {
const card = document.querySelector('#card-to-be-printed');
html2canvas(card)
.then((canvas) => {
let pdfElement = document.getElementById('pdf');
pdfElement.appendChild(canvas);
let doc = new jsPDF('portrait', 'mm', 'a4');
// set image
doc.addImage(canvas.toDataURL('image/png'), 'PNG', 5, 5);
// Set Cairo Font
doc.addFileToVFS('Cairo-Regular.ttf', Cairo);
doc.addFont('Cairo-Regular.ttf', 'Cairo-Regular', 'normal');
doc.setFont('Cairo-Regular');
doc.setFontSize(15);
// set student name
const studentName = doc.processArabic(student.name);
console.log(studentName);
doc.text(studentName, 52, 27.5, { align: 'center' });
doc.save(`student_${student.id}.pdf`);
pdfElement.innerHTML = '';
});
this.$emit('success', student);
this.dialog = false;
}
}
};
</script>
- The console.log(studentName); print this line:

- But the generated pdf contains the text without some characters:

These Characters are missing: ــــ اــــ أـــ اــــم
Changing the font works. You could try Amiri.
This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant.
i'm having the same problem
@moh-slimani this comment may help you: https://github.com/niklasvh/html2canvas/issues/686#issuecomment-552733490
@moh-slimani this comment may help you: niklasvh/html2canvas#686 (comment)
i fixed the problem with changing the font it would have been great if i could use the Cairo font which seem to be the only font that has this issue so far thanks anyway
Almarai font has the same issue