用JSPDF创建PDF,不用外语工作
我正在尝试使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论