DavBfr / dart_pdf

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

Not Support Arabic language #1401

Open mhamouda-cliko opened 1 year ago

mhamouda-cliko commented 1 year ago

Describe the bug

To Reproduce Code snippet to reproduce the behavior:

// your code

Expected behavior

Screenshots

Flutter Doctor

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context

sosocom commented 1 year ago

you should choose the correct font for your language. This is my example for chinese. pw.MultiPage( pageTheme: _buildTheme( pageFormat, await PdfGoogleFonts.notoSerifHKRegular(), await PdfGoogleFonts.notoSerifHKBold(), await PdfGoogleFonts.notoSerifHKLight(), ),

NALAWALAMURTUZA commented 1 year ago

@sosocom

Arabic font does not support

 pw.MultiPage(
        pageTheme: _buildTheme(
          format,
          await PdfGoogleFonts.notoNaskhArabicRegular(),
          await PdfGoogleFonts.notoNaskhArabicBold(),
          await PdfGoogleFonts.notoNaskhArabicRegular(),
        ), 

Text code

        color: PdfColors.green,
        width: double.infinity,
        child: pw.Text(
          AppLocalizations.of(c)
                  ?.translate('lbl_successful_message')
                  .replaceAll(
                      'Closing_Date', payment.bid?.closingDate.value ?? '') ??
              '',
          textDirection: pw.TextDirection.ltr,
          style: pw.TextStyle(
              fontSize: 14,
              color: PdfColors.black,
              fontWeight: pw.FontWeight.bold,
              font: font),
        ),
      );`

actual output

Screenshot (17)

Getting output that is incorrect

Screenshot (18)

Karim-Monir commented 1 year ago

just use: textDirection: pw.TextDirection.rtl it works fine that way and Arabic renders the right way