Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdf viewer - Search Arabic words #2158

Open
AbanoubFakheryMakram opened this issue Nov 7, 2024 · 1 comment
Open

pdf viewer - Search Arabic words #2158

AbanoubFakheryMakram opened this issue Nov 7, 2024 · 1 comment
Labels
open Open pdf viewer PDF viewer component

Comments

@AbanoubFakheryMakram
Copy link

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
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<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  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: <Widget>[
          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

Stack Traces

Stack Traces
No strack trace availabe

On which target platforms have you observed this bug?

Android, iOS

Flutter Doctor output

Doctor output
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
Copy link

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:

  • Flutter Version: 3.22.2
  • Syncfusion Version: ^27.1.58

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!

@AbanoubFakheryMakram AbanoubFakheryMakram changed the title Search Arabic word pdf viewer - Search Arabic words Nov 10, 2024
@VijayakumarMariappan VijayakumarMariappan added pdf viewer PDF viewer component open Open labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open Open pdf viewer PDF viewer component
Projects
None yet
Development

No branches or pull requests

3 participants