Arabic coding with html2canvas

I use html2canvas to get a div image, content from the same page in the same domain, but it shows that the Arabic letters are disabled, it seems that html2canvas does not support Arabic.

While I read the available information about this on my web page, I did not find any useful information.

Here is the simple code I used:

 $("#import").click(function(){ // send the contents of the email :) html2canvas(document.body, { onrendered: function(canvas) { document.body.appendChild(canvas); }, letterRendering:true }); }); 

how html2canvas renders the div

any clue?

+5
source share
4 answers

I was thinking about trying to manipulate the code, and it worked unambiguously. The answer is to replace:

 textList = (!options.letterRendering && /^(left|right|justify|auto)$/.test(textAlign) && noLetterSpacing(getCSS(el, "letterSpacing"))) 

with:

 textList = (!options.letterRendering || /^(left|right|justify|auto)$/.test(textAlign) || noLetterSpacing(getCSS(el, "letterSpacing"))) 

on the sign (&), which is replaced by (||).

+3
source

Do you use UTF-8 encoding? If you do not have <meta http-equiv="content-type" content="text/html; charset=UTF8"> in your head, this will definitely not work :) I hope this helps.

0
source

This is a bug in html2canvas . A solution to this problem can be achieved by setting CSS in your content:

 text-align: left; //or right or justify 

More details here: https://github.com/niklasvh/html2canvas/issues/226#issuecomment-20232693

0
source

Please make sure yo does the correct "text-align: right;"; in every arabic element

 text-align: right; 

http://jsfiddle.net/8ypxW/2022/

0
source

Source: https://habr.com/ru/post/988259/


All Articles