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.58k stars 774 forks source link

[syncfusion_flutter_pdfviewer] Annotations are incorrectly positioned when the PDF is edited using Firefox's PDF editor. #2043

Closed hm21 closed 1 month ago

hm21 commented 2 months ago

Bug description

When a user edits a PDF file using Firefox's internal PDF editor and later opens it with the syncfusion_flutter_pdfviewer, all annotations are offset on the y-axis. However, if the PDF is edited in the syncfusion_flutter_pdfviewer and then opened in Firefox, the annotations display correctly.

Steps to reproduce

  1. Open a PDF in Firefox and highlight some text. Alternatively, you can use ngx-extended-pdf-viewer in any browser, which produces the same effect.
  2. Open the edited file with syncfusion_flutter_pdfviewer.

Code sample

Code sample ```dart @override Widget build(BuildContext context) { return SfPdfViewer.asset( 'assets/document.pdf', /// edited document ); } ```

Screenshots or Video

Screenshots / Video demonstration
**Original** ![image](https://github.com/user-attachments/assets/24478ade-b803-4848-b887-8597ecff9ad1) **In `syncfusion_flutter_pdfviewer`** ![image](https://github.com/user-attachments/assets/e9e68530-1342-4b30-b265-a577d157efe8)

Stack Traces

No stacktrace

On which target platforms have you observed this bug?

Android, Windows

Flutter Doctor output

Doctor output ```console [√] Flutter (Channel stable, 3.24.0, on Microsoft Windows [Version 10.0.22631.4112]) • Flutter version 3.24.0 on channel stable at C:\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 80c2e84975 (4 weeks ago), 2024-07-30 23:06:49 +0700 • Engine revision b8800d88be • Dart version 3.5.0 • DevTools version 2.37.2 [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at C:\Users\...\AppData\Local\Android\Sdk • Platform android-34, build-tools 34.0.0 • ANDROID_HOME = C:\Users\...\AppData\Local\Android\Sdk • ANDROID_SDK_ROOT = C:\Users\...\AppData\Local\Android\Sdk • Java binary at: C:\Program Files\Android\Android Studio1\jbr\bin\java • Java version OpenJDK Runtime Environment (build 17.0.10+0--11572160) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.5.0) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community • Visual Studio Community 2022 version 17.5.33414.496 • Windows 10 SDK version 10.0.22000.0 [!] Android Studio (version 2023.2) • Android Studio at C:\Program Files\Android\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 X Unable to determine bundled Java version. • Try updating or re-installing Android Studio. [√] Android Studio (version 2023.3) • Android Studio at C:\Program Files\Android\Android Studio1 • 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 17.0.10+0--11572160) [√] VS Code (version 1.92.2) • VS Code at C:\Users\...\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.18.0 [√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22631.4112] • Chrome (web) • chrome • web-javascript • Google Chrome 128.0.6613.85 • Edge (web) • edge • web-javascript • Microsoft Edge 127.0.2651.98 [√] Network resources • All expected network resources are available. ```

Version

syncfusion_flutter_pdfviewer: ^26.2.11

immankumarsync commented 2 months ago

@hm21, we are able to replicate the issue, currently we are validating the issue. The fix for the issue will be available in any of our upcoming weekly release.

immankumarsync commented 1 month ago

Hi @hm21, The fix for the reported issue "Incorrect bounds are retrieved from text markup annotations created using the Firefox PDF viewer" has been included in our weekly release v26.2.14.

Kindly use the following link to refer to latest release version, syncfusion_flutter_pdfviewer 26.2.14

Root cause: When retrieving the bounds collection from a text markup annotation, we parse the quad points from the annotation dictionary. The text markup annotation created by the Firefox PDF viewer uses a different ordering of the quad points compared to our library, leading to incorrect bounds retrieval.

hm21 commented 1 month ago

Hi @immankumarsync I have tested everything, and it works perfectly. Thank you very much for the prompt and efficient fix.