Missing characters when rendering an arabic text
See original GitHub issueHey,
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: ــــ اــــ أـــ اــــم
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Missing characters when rendering an arabic text · Issue #2613
Hey, As the title says, I have Cairo-Regular-normal.js file contains: export const Cairo = 'AAEAAAARAQAABA.....'; And Card.js file contians:
Read more >iText & Arabic pdfs ocasionally missing characters
In our case - The document was authored in MS Word in Arabic. When you select a single character and Alt+x, in MS...
Read more >Arabic characters do not display correctly when saving and ...
When I save a text file with arabic letters from Notepad, they do not show correctly after reopening. Instead it shows ?
Read more >Fixing Arabic fonts typing problem in Adobe illustrator|Super fast
Even with a font that supports Arabic text (e.g. Arial), the text is back to front (left to right, not right to left)...
Read more >If non-Latin fonts don't appear correctly on Mac - Apple Support
On your Mac, change the order of your preferred languages to have text appear correctly in Chinese, Japanese, Korean, Arabic, Persian, and more....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
@moh-slimani this comment may help you: https://github.com/niklasvh/html2canvas/issues/686#issuecomment-552733490