Flutter 尝试在Flatter中创建不同语言的pdf
我想在我的PDF中打印印地语,我也尝试过使用谷歌的Raleway-Regular.ttf字体,但也没用Flutter 尝试在Flatter中创建不同语言的pdf,flutter,pdf,fonts,Flutter,Pdf,Fonts,我想在我的PDF中打印印地语,我也尝试过使用谷歌的Raleway-Regular.ttf字体,但也没用 final font = await rootBundle.load("fonts/ARIAL.TTF"); final ttf = pw.Font.ttf(font); pdf.addPage( pw.MultiPage( pageFormat: PdfPageFormat.a4, margin: pw.EdgeInsets.all(32),
final font = await rootBundle.load("fonts/ARIAL.TTF");
final ttf = pw.Font.ttf(font);
pdf.addPage(
pw.MultiPage(
pageFormat: PdfPageFormat.a4,
margin: pw.EdgeInsets.all(32),
build: (pw.Context context){
return <pw.Widget>[
pw.Center(
child: pw.Text("मेन",style: pw.TextStyle(fontSize: 16,font: ttf))
),
pw.SizedBox(height: 20),
pw.Center(
child: pw.Text("ABC",style: pw.TextStyle(fontSize: 16))
),
),
),
final font=wait rootBundle.load(“font/ARIAL.TTF”);
最终ttf=pw.Font.ttf(Font);
pdf.addPage(
多页(
页面格式:PdfPageFormat.a4,
裕度:所有边缘集(32),
构建:(pw.Context){
返回[
普华永道中心(
子项:pw.Text(“मेन",样式:pw.TextStyle(字体大小:16,字体:ttf))
),
pw.尺寸箱(高度:20),
普华永道中心(
子项:pw.Text(“ABC”,样式:pw.TextStyle(fontSize:16))
),
),
),
我发现以下错误:
***I/flatter(24862):无法将字符串解码为Latin1。
I/flatter(24862):此字体不支持Unicode字符。
I/flatter(24862):如果您想使用拉丁字符串以外的字符串,请改用TrueType(TTF)字体。
I/颤振(24862):参见
I/颤振(24862):---------------------------------------------
E/flatter(24862):[错误:flatter/lib/ui/ui\u dart\u state.cc(177)]未处理的异常:无效参数(字符串):包含无效字符。:”मेन"
我也面临同样的错误,因为您使用的字体不支持该语言,如果您想使用印地语,那么您可以使用hind-regular.ttl字体它支持印地语和英语两种字体 这是我得到的例子 //步骤1-在pubspec中添加字体位置 字体: -家庭:hind 字体: -资产:资产/hind.ttf //步骤2- 最终pdf=pw.Document() 然后在fontStyle中应用这个ttf 我使用的软件包- 将“package:universal_html/html.dart”导入为html 导入“package:pdf/widgets.dart”作为pw 通用html:^1.2.3
pdf:^1.11.1Unicode翻译存在一些问题。请注意 您可以使用syncfusion pdf库(您需要购买订阅)。您将获得各种支持,包括搜索、rtl、unicode支持
final font = await rootBundle.load("assets/fonts/hind.ttf");
final ttf = Font.ttf(font);
final pdf = pw.Document();
pw.Text(
'Your text',
textDirection:TextDirection.rtl, // If you need in opp direction like urdu
style: pw.TextStyle(
font: ttf,))
我有一种预感,ARIAL不支持拉丁语以外的任何语言,而印地语不能用拉丁语表达。你需要更完整的字体。好的,谢谢,我会尽量让你知道的。
final font = await rootBundle.load("assets/fonts/hind.ttf");
final ttf = Font.ttf(font);
final pdf = pw.Document();
pw.Text(
'Your text',
textDirection:TextDirection.rtl, // If you need in opp direction like urdu
style: pw.TextStyle(
font: ttf,))