Reactjs 使用阿拉伯语字体生成Pdf
我想在react中下载一个带有阿拉伯语字体的pdf文件,但还没有找到任何解决方案。我目前正在使用jsPdf,但它不能正确地呈现阿拉伯语字体Reactjs 使用阿拉伯语字体生成Pdf,reactjs,pdf,utf-8,arabic,jspdf,Reactjs,Pdf,Utf 8,Arabic,Jspdf,我想在react中下载一个带有阿拉伯语字体的pdf文件,但还没有找到任何解决方案。我目前正在使用jsPdf,但它不能正确地呈现阿拉伯语字体 let doc = new PDFDocument let doc = new pdf(); doc.setFontSize(10); doc.rect(20, 20, doc.internal.pageSize.getWidth() - 40, doc.internal.pageSize.getHeight() - 40, 'S'); doc.setTe
let doc = new PDFDocument
let doc = new pdf();
doc.setFontSize(10);
doc.rect(20, 20, doc.internal.pageSize.getWidth() - 40,
doc.internal.pageSize.getHeight() - 40, 'S');
doc.setTextColor(128,0,128);
doc.text("Date", 30, 25);
doc.text(this.state.date, 50, 25);
doc.text("السلام عليكم", 30, 35);
doc.text("Quantity", 120, 35);
let distance = 30;
doc.save("data.pdf");
提前感谢您是否尝试添加{lang:'value'}选项
doc.text(['لا إله إلا الله محمد رسول الله', 'لا إله إلا الله', 'a'], 100, 100, { lang: 'ar' });
您是否尝试添加{lang:'value'}选项
doc.text(['لا إله إلا الله محمد رسول الله', 'لا إله إلا الله', 'a'], 100, 100, { lang: 'ar' });
通过以下步骤,可以将阿拉伯文字体打印成pdf
可以按照以下步骤将阿拉伯语字体打印成pdf
首先下载所需的字体。然后去 并转换并下载该文件。将其移动到项目目录,并将其导入所需的模块中 也可以将大字符串放入变量
const myFont“VVV…VVV”
然后像这样使用它
doc.addFileToVFS("MyFont.ttf", myFont);
doc.addFont("MyFont.ttf", "MyFont", "normal");
doc.setFont("MyFont");
现在需要右对齐文本
doc.text("Arabic Text", 200, 20, "right");
/*
200 is the x coordinate and marks the starting position of the text from right.
y coordinate is the distance from the top of the page.
*/
首先下载所需的字体。然后去 并转换并下载该文件。将其移动到项目目录,并将其导入所需的模块中 也可以将大字符串放入变量
const myFont“VVV…VVV”
然后像这样使用它
doc.addFileToVFS("MyFont.ttf", myFont);
doc.addFont("MyFont.ttf", "MyFont", "normal");
doc.setFont("MyFont");
现在需要右对齐文本
doc.text("Arabic Text", 200, 20, "right");
/*
200 is the x coordinate and marks the starting position of the text from right.
y coordinate is the distance from the top of the page.
*/
你能添加jsPdf吗link@downvoters为什么投反对票?你能加上jsPdf吗link@downvoters为什么投反对票?是的,但仍不能正确渲染。是的,但仍不能正确渲染。谢谢!这就是我要找的!谢谢这就是我要找的!