Mohsin Patel
Mohsin Patel

Reputation: 31

Issue generating Marathi Language PDF in Flutter

In my project, according to requirements, I need to generate a PDF in multiple languages. I am able to do so in English perfectly, but I am facing issues when it comes to Marathi or Hindi language. I am getting the generated PDF, but the Marathi and Hindi texts are breaking.

For example: The text I want to print is "पेमेंट रजिस्टर", but inside the PDF print, I am getting the text as enter image description here

How can i make it work as per the text i want? Here is my code snippet

Future<pw.Document> createPDF(List<dynamic> paymentRegister) async {
  final pdf = pw.Document();

  final fontData = await rootBundle.load('assets/fonts/NotoSans-Regular.ttf');
  final font = pw.Font.ttf(fontData);

  pdf.addPage(
    pw.MultiPage(
      build: (context) => [
        pw.Text('पेमेंट रजिस्टर'.tr,
            style: pw.TextStyle(fontSize: 22, font: font)),
        
      ], // Removed the extra closing bracket here
    ),
  );

  return pdf;
}

Upvotes: 0

Views: 223

Answers (0)

Related Questions