syncfusion / flutter-widgets

Syncfusion Flutter widgets libraries include high quality UI widgets and file-format packages to help you create rich, high-quality applications for iOS, Android, and web from a single code base.
1.6k stars 782 forks source link

pdf viewer - Search Arabic words #2158

Open AbanoubFakheryMakram opened 2 weeks ago

AbanoubFakheryMakram commented 2 weeks ago

Bug description

When searching for a word in Arabic pdf file no results found, while copying this word from the file and past it inside searchController the controller find it

_searchResult = _pdfViewerController.searchText("ﻛﯿﻒ");

Steps to reproduce

  1. Use this file as ref "https://www.ed.gov/sites/ed/files/about/offices/list/ocr/docs/qa-201405-arabic.pdf"

  2. Try to give the controller a direct word "simulate a user search" => pdfViewerController.searchText("ﻛﯿﻒ"); Expected: The controller could find the word Actual: The controller can not find this word

  3. Try copy any word from the file and past as it inside the controller Here the controller can find the word

Code sample

Code sample ```dart import 'dart:convert'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); final String title; @override State createState() => _MyHomePageState(); } class _MyHomePageState extends State { late PdfViewerController _pdfViewerController; late PdfTextSearchResult _searchResult; @override void initState() { _pdfViewerController = PdfViewerController(); _searchResult = PdfTextSearchResult(); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, title: Text(widget.title), actions: [ IconButton( icon: const Icon( Icons.search, color: Colors.white, ), onPressed: () { _searchResult = _pdfViewerController.searchText("ﻛﯿﻒ"); if (kIsWeb) { print('Total instance count: ${_searchResult.totalInstanceCount}'); } else { _searchResult.addListener( () { if (_searchResult.hasResult && _searchResult.isSearchCompleted) { print('Total instance count: ${_searchResult.totalInstanceCount}'); } else { print('no search result'); } }, ); } }, ), ], ), floatingActionButton: FloatingActionButton( onPressed: () { _searchResult.nextInstance(); }, child: const Icon(Icons.next_plan_outlined), ), body: SfPdfViewer.network( 'https://www.ed.gov/sites/ed/files/about/offices/list/ocr/docs/qa-201405-arabic.pdf', controller: _pdfViewerController, currentSearchTextHighlightColor: Colors.blue.withOpacity(.4), otherSearchTextHighlightColor: Colors.yellow.withOpacity(.4), ), ); } } ```

Screenshots or Video

Screenshots / Video demonstration ![image](https://github.com/user-attachments/assets/801403ab-cc30-41fb-8fed-928d2224b6c2)

Stack Traces

Stack Traces ```dart No strack trace availabe ```

On which target platforms have you observed this bug?

Android, iOS

Flutter Doctor output

Doctor output ```console Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.24.2, on macOS 14.0 23A344 darwin-arm64, locale en-US) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2024.1) [✓] Connected device (4 available) ! Error: Browsing on the local area network for iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac. The device must be opted into Developer Mode to connect wirelessly. (code -27) [✓] Network resources • No issues found! ```
ismailelmogy commented 2 weeks ago

I am also experiencing this issue with searching Arabic text in syncfusion_flutter_pdfviewer. When I use the searchText feature for Arabic words, it fails to find the correct results or sometimes does not locate the text at all.

My Setup:

Steps to Reproduce:

  1. Load a PDF with Arabic content.
  2. Attempt to search for an Arabic word or phrase using the searchText function.
  3. Observe that the function does not return the expected results.

I’d appreciate any updates on resolving this issue. Thank you!