DavBfr / dart_pdf

Pdf creation module for dart/flutter
https://pub.dev/packages/pdf
Apache License 2.0
1.36k stars 593 forks source link

Printing's PDF preview is almost never presented on Linux #1685

Open electronicoit opened 5 days ago

electronicoit commented 5 days ago

Describe the bug When using the Printing package, its PDF preview is almost never presented on Linux; a white page is shown instead. Sometimes, after playing around with on-screen controls (page orientation, page format, debug guidelines), the actual content of the page is shown. But, if one keeps playing with the controls or window size, it disappears again.

Always on Linux, and with any project. Even with: https://github.com/DavBfr/dart_pdf/tree/master/printing/example

If I modify the code so that the generated PDF is written to disk and then loaded, the same happens.

If I modify the example for showing any PDF on my disk, the same happens unless it's a multi-page PDF. In this case, only the first page is shown but the rest remains empty (white).

Also, the Share button presents a 'Document Viewer' window with no icons on all buttons; only a red cancel/error/not-found icon.

To Reproduce Code snippet to reproduce the behavior:

// Just run on Linux with the latest version of flutter:
//
// https://github.com/DavBfr/dart_pdf/tree/master/printing/example
//

Expected behavior The full PDF is shown on every occasion.

Screenshots When it does not work (the usual): Screenshot from 2024-06-25 12-16-43

When it does work (sometimes after playing with the controls): Screenshot from 2024-06-25 12-18-28

Flutter Doctor

flutter doctor -v
[✓] Flutter (Channel stable, 3.22.2, on Ubuntu 22.04.4 LTS 6.5.0-41-generic, locale en_US.UTF-8)
    • Flutter version 3.22.2 on channel stable at /home/myusername/Tools/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 761747bfc5 (3 weeks ago), 2024-06-05 22:15:13 +0200
    • Engine revision edd8546116
    • Dart version 3.4.3
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /home/myusername/Tools/Android/Sdk
    • Platform android-34, build-tools 33.0.1
    • Java binary at: /home/myusername/Tools/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • Ubuntu clang version 14.0.0-1ubuntu1.1
    • cmake version 3.22.1
    • ninja version 1.10.1
    • pkg-config version 0.29.2

[✓] Android Studio (version 2024.1)
    • Android Studio at /home/myusername/Tools/android-studio
    • Flutter plugin version 80.0.2
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /home/myusername/Tools/android-studio
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)

[✓] VS Code (version 1.90.2)
    • VS Code at /snap/code/current/usr/share/code
    • Flutter extension version 3.90.0

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 22.04.4 LTS 6.5.0-41-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 126.0.6478.126

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Desktop (please complete the following information):

Smartphone (please complete the following information): No

Additional context N/A

electronicoit commented 3 days ago

Tested with two different versions of pre-compiled PDFium, 5200 and 6555. The same problem is present in both cases.


pubspec.yaml


environment: sdk: '>=3.3.0 <4.0.0'

dependencies: flutter: sdk: flutter

cupertino_icons: ^1.0.6 go_router: ^14.1.4 intl: ^0.19.0 uuid: ^4.3.2 data_table_2: ^2.5.11 provider: ^6.1.2 email_validator: ^2.1.16 path_provider: ^2.1.3 qr_flutter: ^4.1.0 image_picker: ^1.1.2 mobile_scanner: ^5.1.1 pdf: ^3.10.8 printing: ^5.12.0

dev_dependencies: flutter_test: sdk: flutter integration_test: sdk: flutter

flutter_lints: ^4.0.0

flutter: uses-material-design: true