DavBfr / dart_pdf

Pdf creation module for dart/flutter
https://pub.dev/packages/pdf
Apache License 2.0
1.36k stars 593 forks source link

Bangla text Rendering issue. #1639

Open helper-bud opened 3 months ago

helper-bud commented 3 months ago

getting this bangla text. Screenshot 2024-03-30 112609 want this bangla text. Screenshot 2024-03-30 144903

when i am copying from the generated pdf, and pasting some where else the text gets right.

code : final pdf = pw.Document(); var logger = Logger();

final banglaFont =
    await rootBundle.load("assets/fonts/AnekBangla/kalpurush.ttf");
final banglaFontTtf = pw.Font.ttf(banglaFont);

pw.Table( border: pw.TableBorder.all(), children: [ pw.TableRow( pw.Text("${innerLoop.groupid} - ${innerLoop.grpnam}", style: pw.TextStyle( font: banglaFontTtf, fontSize: 6, ), textAlign: pw.TextAlign.center, maxLines: 1), ) ]

)

bksbora commented 1 month ago

Kemon acho vai ,it seems same to me :D I don't know the solution i just wanted to say hi !

bksbora commented 1 month ago

Oh you should look at this. I guess for Bangla ,help needed. #219

Tarikul-Islam-Shykat commented 1 week ago

solved it. using unicode to bijoy. suppose this is the text : innerLoop.grpnam.toString() in this code :

pw.Text( "${innerLoop.groupid} - ${CodeUtil.unicodeToBijoyText(innerLoop.grpnam.toString())}", style: pw.TextStyle( font: banglaFontTtf, fontSize: 6, )

   static String unicodeToBijoyText(String text) {
return unicodeToBijoy(utf8.decode(utf8.encode(text)));

}

Tarikul-Islam-Shykat commented 1 week ago

i found that solution by on the day when i found it. but posting it hope it helps.