Skip to content

PDF does't render on Android but it works fine on web. #1524

@niklasmiller12

Description

@niklasmiller12

Simply try this HTML with below piece of Code on Android and you will see a black page as result. But you will see the PDF as you run app on Flutter Web.
Tried these two versions but result is same:
fwfh_webview: ^0.15.3
fwfh_webview: ^0.15.6

This HTML works perfectly on web but it displays a back page on Android. I have attached the Code sample below.

class PageContentEmbed extends StatelessWidget {
  final String htmlString;

  const PageContentEmbed(this.htmlString, {Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return HtmlWidget(
      htmlString,
      factoryBuilder: () => MyWidgetFactory(),
    );
  }
}

class MyWidgetFactory extends WidgetFactory with WebViewFactory {
  // optional: override getter to configure how WebViews are built
  @override
  bool get webViewMediaPlaybackAlwaysAllow => true;
  @override
  String? get webViewUserAgent => 'My app';
}

###Attached screenshot of my web app where it works fine and same behaviour is expected on Android
Image

###This is what I see on Android:

Image
[✓] Flutter (Channel stable, 3.35.3, on macOS 26.0.1 25A362 darwin-arm64, locale en-PK) [244ms]
    • Flutter version 3.35.3 on channel stable at /Users/niklas/Documents/sdks/3.35.3/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a402d9a437 (5 weeks ago), 2025-09-03 14:54:31 -0700
    • Engine revision ddf47dd3ff
    • Dart version 3.9.2
    • DevTools version 2.48.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-lldb-debugging

[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0-rc1) [998ms]
    • Android SDK at /Users/niklas/Library/Android/sdk
    • Emulator version 35.3.11.0 (build_id 12836668) (CL:N/A)
    • Platform android-36, build-tools 36.1.0-rc1
    • ANDROID_HOME = /Users/niklas/Library/Android/sdk
    • Java binary at: /Users/niklas/Library/Java/JavaVirtualMachines/corretto-17.0.14/Contents/Home/bin/java
      This JDK is specified in your Flutter configuration.
      To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment Corretto-17.0.14.7.1 (build 17.0.14+7-LTS)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 26.0.1) [942ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 17A400
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [7ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2) [7ms]
    • 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 21.0.4+-12422083-b607.1)

[✓] Connected device (3 available) [6.1s]
    • V2249 (mobile)  • 10FD8R02B40003D • android-arm64  • Android 15 (API 35)
    • macOS (desktop) • macos           • darwin-arm64   • macOS 26.0.1 25A362 darwin-arm64
    • Chrome (web)    • chrome          • web-javascript • Google Chrome 141.0.7390.55

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

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions