Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Syncfusion Flutter PDF Viewer throws 'Invalid value: Not in inclusive range' during text selection #2342

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

Open
minhto2811 opened this issue Apr 29, 2025 · 2 comments
Labels
follow-up scheduled Follow-up scheduled pdf viewer PDF viewer component

Comments

@minhto2811
Copy link

Bug description

When selecting text in a PDF using the syncfusion_flutter_pdfviewer package, the app throws the following error and sometimes crashes:

Image

This occurs during text selection—often when dragging across multiple lines or pages. It appears to be a RangeError, likely caused by incorrect indexing when calculating selection ranges.

Attached PDF file

Steps to reproduce

1.Open a PDF using SfPdfViewer.asset() (or SfPdfViewer.network()).

2.Long-press on a word to start text selection.

3.Drag to extend the selection across multiple lines or to the end of a page.

4.Observe that the app crashes or throws the error

Code sample

class PdfView extends StatelessWidget {
  const PdfView(
      {super.key,
      required this.bytes,
      required this.initialPageNumber,
      this.onPageChanged,
      required this.key1,
      this.onHyperlinkClicked,
      required this.controller});

  final Uint8List bytes;
  final int initialPageNumber;
  final void Function(PdfPageChangedDetails)? onPageChanged;
  final GlobalKey<SfPdfViewerState> key1;
  final Function(PdfHyperlinkClickedDetails)? onHyperlinkClicked;
  final PdfViewerController controller;

  @override
  Widget build(BuildContext context) {
    return SfPdfViewer.memory(
      bytes,
      key: key1,
      initialPageNumber: initialPageNumber,
      onPageChanged: onPageChanged,
      onHyperlinkClicked: onHyperlinkClicked,
      controller: controller,
      canShowPageLoadingIndicator: false,
      canShowTextSelectionMenu: false,
    );
  }
}

```yaml
  syncfusion_flutter_pdfviewer: ^29.1.39
  syncfusion_flutter_pdf: ^29.1.39
  syncfusion_localizations: ^29.1.37

Screenshots or Video

Image

Stack Traces

Stack Traces
[Add the Stack Traces here]

On which target platforms have you observed this bug?

Android, iOS

Flutter Doctor output

Doctor output
[Add your output here]
@VijayakumarMariappan VijayakumarMariappan added pdf viewer PDF viewer component open Open labels Apr 30, 2025
@immankumarsync
Copy link
Contributor

Hi @minhto2811,

We are able to replicate the Range error when extracting text lines from the PDF page. Currently, we are validating this issue, and we will update further details once it is completed

Regards,
Imman Kumar P

@Deepak1799 Deepak1799 added follow-up scheduled Follow-up scheduled and removed open Open labels Apr 30, 2025
@immankumarsync
Copy link
Contributor

We confirmed the issue "Range Error exception in extractTextLines API" as a defect in our product and we will include the fix in the upcoming weekly release, which will be available on May 20, 2025.

Please use the below feedback link to track the status of the reported bug.
Range Error exception in extractTextLines API in Flutter PDF in Flutter | Feedback Portal

Disclaimer: "Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
follow-up scheduled Follow-up scheduled pdf viewer PDF viewer component
Projects
None yet
Development

No branches or pull requests

4 participants