DavBfr / dart_pdf

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

English words are not in the correct order when mixed with Arabic and splitted to multiple lines #1476

Open HasanAlqaisi opened 1 year ago

HasanAlqaisi commented 1 year ago

Describe the bug

When we mix Arabic and English words, the order of the English words is not correct when they split into multiple lines

To reproduce

  Future<Uint8List> _generatePdf(PdfPageFormat format, String title) async {
    final pdf = pw.Document(version: PdfVersion.pdf_1_5);
    final fontStyle = pw.TextStyle(
      fontSize: 50,
      fontWeight: pw.FontWeight.bold,
      font: await PdfGoogleFonts.iBMPlexSansArabicRegular(),
    );
    pdf.addPage(
      pw.Page(
        pageFormat: format,
        build: (context) {
          return pw.Text(
            'قررت أن أقوم برحلة استكشافية إلى the historical old town',
            style: fontStyle,
            textDirection: pw.TextDirection.rtl,
          );
        },
      ),
    );

    return pdf.save();
  }

Screenshots Current behavior: photo_2023-09-07_17-18-19

Expected behavior (To be in the correct order): photo_2023-09-07_17-20-46

Flutter Doctor

[✓] Flutter (Channel stable, 3.13.2, on Linux Mint 21.2 5.15.0-82-generic,
    locale en_US.UTF-8)
    • Flutter version 3.13.2 on channel stable at
      /home/hasan/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ff5b5b5fa6 (2 weeks ago), 2023-08-24 08:12:28 -0500
    • Engine revision b20183e040
    • Dart version 3.1.0
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /home/hasan/Android/Sdk
    • Platform android-33-ext4, build-tools 33.0.2
    • Java binary at: /home/hasan/development/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build
      11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 13.0.0 (https://github.com/apple/llvm-project.git
      c41f13252ed4b49f246729b4d91ff521d5a6bf9d)
    • cmake version 3.22.1
    • ninja version 1.10.1
    • pkg-config version 0.29.2

[✓] Android Studio (version 2022.1)
    • Android Studio at /home/hasan/development/android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      11.0.15+0-b2043.56-8887301)

[✓] VS Code (version 1.81.1)
    • VS Code at /usr/share/code
    • Flutter extension version 3.72.0

[✓] Connected device (3 available)
    • SM N960F (mobile) • 2b32ca38291c7ece • android-arm64  • Android 13 (API
      33)
    • Linux (desktop)   • linux            • linux-x64      • Linux Mint 21.2
      5.15.0-82-generic
    • Chrome (web)      • chrome           • web-javascript • Google Chrome
      116.0.5845.140

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Desktop (please complete the following information):

Smartphone (please complete the following information):

NALAWALAMURTUZA commented 1 year ago

in fluter web receive the below error with the same example

Error: Unsupported operation: Platform._operatingSystem ../dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 294:49 throw_ ../dart-sdk/lib/_internal/js_dev_runtime/patch/io_patch.dart 244:5 _operatingSystem ../dart-sdk/lib/io/platform_impl.dart 56:40 get operatingSystem ../dart-sdk/lib/io/platform.dart 83:44 get operatingSystem ../dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 1220:8 get ../dart-sdk/lib/io/platform.dart 146:48 get isMacOS ../dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 1220:8 get ../packages/printing/src/print_job.dart 77:32 add ../packages/printing/src/method_channel.dart 182:28 layoutPdf ../dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody ../dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5 _async ../packages/printing/src/method_channel.dart 174:25 layoutPdf ../packages/printing/src/printing.dart 49:38 layoutPdf ../packages/client/presentation/bid/detail/bid_print.dart 22:28 <fn> ../dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody ../dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5 _async ../packages/client/presentation/bid/detail/bid_print.dart 21:22 <fn> ../packages/flutter/src/material/ink_well.dart 1154:21 handleTap ../packages/flutter/src/gestures/recognizer.dart 275:24 invokeCallback ../packages/flutter/src/gestures/tap.dart 654:11 handleTapUp ../packages/flutter/src/gestures/tap.dart 311:5 [_checkUp] ../packages/flutter/src/gestures/tap.dart 244:7 handlePrimaryPointer ../packages/flutter/src/gestures/recognizer.dart 630:9 handleEvent ../packages/flutter/src/gestures/pointer_router.dart 98:12 [_dispatch] ../packages/flutter/src/gestures/pointer_router.dart 143:9 <fn> ../dart-sdk/lib/_internal/js_dev_runtime/private/linked_hash_map.dart 21:13 forEach ../packages/flutter/src/gestures/pointer_router.dart 141:17 [_dispatchEventToRoutes] ../packages/flutter/src/gestures/pointer_router.dart 127:7 route ../packages/flutter/src/gestures/binding.dart 488:19 handleEvent ../packages/flutter/src/gestures/binding.dart 468:14 dispatchEvent ../packages/flutter/src/rendering/binding.dart 333:11 dispatchEvent ../packages/flutter/src/gestures/binding.dart 413:7 [_handlePointerEventImmediately] ../packages/flutter/src/gestures/binding.dart 376:5 handlePointerEvent ../packages/flutter/src/gestures/binding.dart 323:7 [_flushPointerEventQueue] ../packages/flutter/src/gestures/binding.dart 292:9 [_handlePointerDataPacket] ../lib/_engine/engine/platform_dispatcher.dart 1319:13 invoke1 ../lib/_engine/engine/platform_dispatcher.dart 303:5 invokeOnPointerDataPacket ../lib/_engine/engine/pointer_binding.dart 168:39 [_onPointerData] ../lib/_engine/engine/pointer_binding.dart 791:20 <fn> ../lib/_engine/engine/pointer_binding.dart 720:14 <fn> ../lib/_engine/engine/pointer_binding.dart 317:16 loggedHandler ../dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 574:37 _checkAndCall ../dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 579:39 dcall

NALAWALAMURTUZA commented 1 year ago

https://github.com/DavBfr/dart_pdf/issues/291#issuecomment-1715526671

ahmed-mohsin commented 2 months ago

did you find any fix for this hassan ?

HasanAlqaisi commented 2 months ago

did you find any fix for this hassan ?

Unfortunately, not yet.

ahmed-mohsin commented 1 month ago

did you find any workaround method to print mix arabic and english text ?

HasanAlqaisi commented 1 month ago

did you find any workaround method to print mix arabic and english text ?

Nope, I am not using it in projects right now so I don't know if there are any workarounds.