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.54k stars 745 forks source link

Issue while peview PDF #1983

Closed Tejas20002 closed 4 days ago

Tejas20002 commented 1 month ago

Bug description

Hey, we're encountering an issue with previewing some PDFs in our Flutter application. The font colors in certain PDFs are changing unexpectedly. This problem doesn't occur with all PDFs, just with some specific ones. We're not sure why this is happening. Could you please look into this and let us know what's going on?

Steps to reproduce

none

Code sample

Code sample ```dart body: SfPdfViewer.file( widget.pdfFile, controller: _pdfViewerController, key: _pdfViewerKey, enableTextSelection: false, interactionMode: PdfInteractionMode.pan, scrollDirection: PdfScrollDirection.vertical, canShowPasswordDialog: false, password: widget.password, pageLayoutMode: PdfPageLayoutMode.single, enableDoubleTapZooming: true, maxZoomLevel: 5, ), ```

Screenshots or Video

Screenshots / Video demonstration Application preview image ![WhatsApp Image 2024-07-12 at 04 10 00](https://github.com/user-attachments/assets/126ce63e-b4fe-4619-a705-cb18f3fe7af7) Original pdf image ![WhatsApp Image 2024-07-12 at 04 12 11](https://github.com/user-attachments/assets/c4b1fadf-89ac-4d89-8df9-2af885545d0c) Original pdf [Math-All-test-7.pdf](https://github.com/user-attachments/files/16261737/Math-All-test-7.pdf)

Stack Traces

Stack Traces No error found

On which target platforms have you observed this bug?

Windows, MacOS, Linux

Flutter Doctor output

Doctor output ```console at 15:06:27 🍎 ➜ flutter doctor -v [!] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-arm64, locale en-US) β€’ Flutter version 3.22.2 on channel stable at /opt/homebrew/Caskroom/flutter/3.19.5/flutter ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/3.4.4/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /opt/homebrew/Caskroom/flutter/3.19.5/flutter. Consider adding /opt/homebrew/Caskroom/flutter/3.19.5/flutter/bin to the front of your path. β€’ Upstream repository https://github.com/flutter/flutter.git β€’ Framework revision 761747bfc5 (6 weeks ago), 2024-06-05 22:15:13 +0200 β€’ Engine revision edd8546116 β€’ Dart version 3.4.3 β€’ DevTools version 2.34.3 β€’ If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [βœ“] Android toolchain - develop for Android devices (Android SDK version 34.0.0) β€’ Android SDK at /Users/macos/Library/Android/sdk β€’ Platform android-34, build-tools 34.0.0 β€’ Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java β€’ Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160) β€’ All Android licenses accepted. [!] Xcode - develop for iOS and macOS (Xcode 15.4) β€’ Xcode at /Applications/Xcode.app/Contents/Developer β€’ Build 15F31d βœ— Unable to get list of installed Simulator runtimes. β€’ CocoaPods version 1.15.2 [βœ“] Chrome - develop for the web β€’ Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [βœ“] Android Studio (version 2023.3) β€’ Android Studio at /Applications/Android Studio.app/Contents β€’ 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-17.0.10b1087.21-11572160) [βœ“] VS Code (version 1.91.0) β€’ VS Code at /Applications/Visual Studio Code.app/Contents β€’ Flutter extension can be installed from: πŸ”¨ https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [βœ“] Connected device (3 available) β€’ macOS (desktop) β€’ macos β€’ darwin-arm64 β€’ macOS 14.5 23F79 darwin-arm64 β€’ Mac Designed for iPad (desktop) β€’ mac-designed-for-ipad β€’ darwin β€’ macOS 14.5 23F79 darwin-arm64 β€’ Chrome (web) β€’ chrome β€’ web-javascript β€’ Google Chrome 126.0.6478.127 [βœ“] Network resources β€’ All expected network resources are available. ! Doctor found issues in 2 categories. ```
hkpanchani commented 1 month ago

Ahh that was the viewer problem, I have been manipulating my pdf files. πŸ˜₯πŸ˜₯

immankumarsync commented 1 month ago

Hi @Tejas20002, We are unable to replicate the reported issue, and the font color of the page text is not changed as reported. Please find the screenshots below,

Windows, image

Web, image

macOS, image

Could you please share the following information to analyze more on this issue?

  1. syncfusion_flutter_pdfviewer package version.
  2. Platform in which the application is deployed.
  3. If deployed on web platform, share the pdf.js script reference added in the index.html file, else ignore
  4. If deployed on web platform, in which browser this issue occurs, else ignore.
Tejas20002 commented 1 month ago

When previewing the PDF with a native app, it displays correctly. However, when opening the same PDF with a plugin, the colors are altered. The PDF is password-protected with the following password: cN}6DmRsb}h2(*s@nAYeu-MIUjBU_48xj9Y5TnwjtPtPeRkoO)

Here is the PDF file: 1.pdf @immankumarsync

syncfusion_flutter_pdfviewer package version: 26.1.42 Platform in which the application is deployed: Windows, MacOS, Linux

immankumarsync commented 1 month ago

@Tejas20002, we are able to replicate the reported issue. Currently, we are validating the issue, and we will update further details once the validation is completed.

However, we are unable to understand the phrase "when opening the same PDF with a plugin." Could you please explain this? Also, the syncfusion_flutter_pdfviewer is not supported on the Linux platform. Could you please explain how you are deploying the app on the Linux platform? Do you build the application for the web and deploy it on a URL?

Tejas20002 commented 1 month ago

@immankumarsync Apologies for the confusion. When I mentioned the plugin, I meant syncfusion_flutter_pdfviewer. We currently don't have a web application; we only work on Windows and MacOS. And by Linux, I meant Androidβ€”I totally forgot about that.

I'm really very sorry about the mistake.

hkpanchani commented 1 month ago

@immankumarsync were you able to replicate the issue and do see any updates for the same? Thank a lot.

immankumarsync commented 1 month ago

The fix for the reported issue "Text color changes when decrypting a specific PDF document" has been included in our weekly release v26.2.7.

Package link: syncfusion_flutter_pdfviewer v26.2.7

Root Cause: When removing the password from an encrypted PDF document, we decrypt all the encrypted content embedded within it. In this case, while decrypting the color space in the document, the lookup parameter, which provides the mapping between index values and the corresponding colors in the base color space, was not properly decrypted and encoded. This caused improper color preservation in the PDF document.

Tejas20002 commented 1 month ago

@immankumarsync awesome, Let me check!

Tejas20002 commented 1 month ago

@immankumarsync Thank you, it seems to be working well for us. We can mark this to Resolved