dart_pdf icon indicating copy to clipboard operation
dart_pdf copied to clipboard

❗️Issue: PDF not displaying in release mode on Flutter 3.32 (works in debug)

Open ebm2243 opened this issue 6 months ago • 13 comments

After upgrading to Flutter SDK 3.32.0, PDF generation using the printing package (^5.14.2) stopped working in release mode on Android. The same code works perfectly in debug mode and with earlier Flutter versions like 3.29.0. When running in release, the app shows the error PDF Error: Unable to display the document, without crashing or throwing any exceptions. I've confirmed this happens even with a minimal example using pdf.Document() and Printing.layoutPdf(). No ProGuard rules are added manually, and all permissions are correctly set. This seems to be a regression or compatibility issue introduced in Flutter 3.32. Please investigate or guide if any changes are required in the plugin or build configuration to fix this.

ebm2243 avatar Jun 16 '25 05:06 ebm2243

I'm also on Flutter 3.32.0, but I don't see any issues (neither in debug nor in release).

My current configuration is:

dependencies:
  pdf: ^3.11.3
  printing: ^5.14.2

ndkVersion       = 28.1.13356709
targetSdkVersion = 34
flutter.compileSdkVersion = 35

Flutter
   • Flutter version 3.32.0 on channel stable
   • Dart version 3.8.0

Android toolchain - develop for Android devices (Android SDK version 35.0.1)
   • Platform android-35, build-tools 35.0.1
   • Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)

distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip

leocirto avatar Jun 16 '25 21:06 leocirto

I am using the same configuration as mentioned above, but I'm still facing the same issue. In debug mode, the PDF prints correctly. However, in release mode, it just shows:

"Unable to display the document."

This was working fine previously, but after updating Flutter and dependencies, the issue started appearing.

compileSdk = 35 ndkVersion = "28.1.13356709"

pdf: ^3.11.3 printing: ^5.14.2

Flutter Doctor Output: [✓] Flutter (Channel stable, 3.32.0, on macOS 15.5 24F74 darwin-x64, locale en-AE) [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 16.3) [✓] Chrome - develop for the web [✓] Android Studio (version 2024.2) [✓] VS Code (version 1.96.2) Dart SDK version: 3.8.0 (stable) (Wed May 14 09:07:14 2025 -0700) on "macos_x64" Please let me know if you need any logs or code samples. Thank you!

ebm2243 avatar Jun 17 '25 06:06 ebm2243

nobody is there to correct this issue ?

ebm2243 avatar Jun 19 '25 05:06 ebm2243

Paste the "minimal example" you mentioned.

leocirto avatar Jun 19 '25 08:06 leocirto

This is also happening for me on WEB platform. Works fine in debug, but after publishing or even using firebase serve it no longer works. On the same versions as the OP.

atebitftw avatar Jul 05 '25 21:07 atebitftw

it stops working when image= await networkImage(url); is used in WASM build web

KaushikGupta007 avatar Jul 09 '25 14:07 KaushikGupta007

my project was not using latest version of archive. After updating archive to 4.0.3 this issue was fixed

KaushikGupta007 avatar Jul 12 '25 07:07 KaushikGupta007

I am also experiencing this. Tried to use dependency override to set archive to 4.0.3 but didnt work.

this is the error I get in console

TypeError: Instance of 'minified:kl': type 'minified:kl' is not a subtype of type 'minified:lL'

gibahjoe avatar Jul 28 '25 20:07 gibahjoe

are you using WASM flag to release web app?

KaushikGupta007 avatar Jul 28 '25 20:07 KaushikGupta007

No. I am not using WASM flag. Just regular flutter run web --release or flutter build web

gibahjoe avatar Jul 28 '25 20:07 gibahjoe

Maybe minimal code sample would help track this issue

KaushikGupta007 avatar Jul 28 '25 20:07 KaushikGupta007

I would work on that.

gibahjoe avatar Jul 28 '25 20:07 gibahjoe

So upon further investigation, the issue was not with the library specifically but with my implementation. For some reason, it only failed in release mode.

The error I was getting was minified so it was hard to track down. I ended up running the app in profile mode then I got a more descriptive error, Another exception was thrown: TypeError: Instance of 'WrapParentData': type 'WrapParentData' is not a subtype of type 'FlexParentData' . Then after looking through my use of the library (A lot of trial and error because the stack trace was not helpful), I found that I was using Spacer() in the actions list. But the actions list is rendered in a Wrap widget not a Column/Row.

Just posting here in case someone else has same issue.

thanks @KaushikGupta007

gibahjoe avatar Jul 28 '25 22:07 gibahjoe