html2pdf.js icon indicating copy to clipboard operation
html2pdf.js copied to clipboard

issue with arabic words

Open lMicklel opened this issue 3 years ago • 3 comments

I have a really strange problem, as you can see in the photo, when i try to generate pdf that contain arabic string, the space between the last two words always gets ignored, i tried everything (quite literally) and i have no idea how to fix this Untitled

lMicklel avatar Nov 13 '21 15:11 lMicklel

hey @lMicklel checkout the issue i raised i think it can help with your issue too: #497

0markill avatar Dec 10 '21 01:12 0markill

@lMicklel I solved my problem by load every latest library like that


<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-promise/4.2.8/es6-promise.min.js" ></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js" ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js" ></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.min.js" ></script>

<script> 
function smartPrint(html, filename = '', orientation = 'portrait') {
    if (filename) {
        filename = filename + ".pdf"
    } else {
        filename = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15) + ".pdf";
    }
    var opt = {
        margin: 1,
        filename: filename,
        image: { type: 'jpeg', quality: 0.98 },
        html2canvas: { scale: 2 },
        jsPDF: { unit: 'in', format: 'letter', orientation: orientation }
    };
    html2pdf().set(opt).from(html).save();

}
//try this
var html='ماهر جابر شقليه';
smartPrint(html);
</script>

the problem with html2pdf.bundle.min.js version

Arafat-Thabet avatar Apr 29 '22 00:04 Arafat-Thabet

I have a strange problem too, with persian or arabic words and numbers... when i don't add space between words the following sentence gets all messed up. now I cannot control users to make sure they use space after every word.

hosseinghs avatar Jun 07 '23 07:06 hosseinghs