用JSPDF创建PDF,不用外语工作

发布于 2025-02-09 16:30:35 字数 549 浏览 0 评论 0原文

我正在尝试使用JSPDF创建PDF,当PDF文件中的文本使用英语时,它的功能很好。问题在于我正在为希伯来语网站创建这个,出于某种原因,PDF内部的文字变成了一个怪异的字符串,其中包含一些与希伯来语无关的怪异字母。

通过在线搜索,我了解这是在许多外语中发生的,但是我还没有找到解决方案。

 const word= 'עברית'; //random word in hebrew
    
   const generatePDF = () => {
        const pdf = new jsPDF('example', 'px', 'a4', 'false');
        pdf.text(60, 60, word);
        pdf.save('example.pdf'); //instead of print the word 'עברית' it prints 'âÑèÙê'
    };
generatePDF();

我进行了一些搜索,我认为可能的解决方案与从CP1255到UTF-8的转换有关,但我不知道这是否是正确的方向,并且还没有设法找到真正的解决方案。

I'm trying to create a pdf with jsPDF and it works great when the text inside the PDF file is in English. The problem is that I'm creating this for a Hebrew website, and for some reason the text inside the pdf becomes a weird string with some weird letters that have nothing to do with Hebrew.

From searching online I understand that this happens in many foreign languages, but I haven't found a solution yet.

 const word= 'עברית'; //random word in hebrew
    
   const generatePDF = () => {
        const pdf = new jsPDF('example', 'px', 'a4', 'false');
        pdf.text(60, 60, word);
        pdf.save('example.pdf'); //instead of print the word 'עברית' it prints 'âÑèÙê'
    };
generatePDF();

I did some searching and I think that a possible solution has something to do with conversions from cp1255 to UTF-8, but I don't know if it's the right direction and haven't managed to find a real solution yet.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文