Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Flutter Web] Printing not working on mobile Safari browser #1737

Open
1 of 5 tasks
MingSern opened this issue Sep 8, 2024 · 0 comments
Open
1 of 5 tasks

[Flutter Web] Printing not working on mobile Safari browser #1737

MingSern opened this issue Sep 8, 2024 · 0 comments
Labels
bug Something isn't working needs triage

Comments

@MingSern
Copy link

MingSern commented Sep 8, 2024

Describe the bug
I'm using Flutter Web and I'm trying to print a pdf file. Printing works expectedly in desktop browser, but when I tested on my iPhone's Safari browser, nothing happens when I tried to print. I am not sure is this suppose to happen or not. I am using iPhone 12, I tried on iPhone 13 as well, same result. The existing demo also have this issue on my device: https://davbfr.github.io/dart_pdf/

To Reproduce

  • iOS device
  • Safari browser
  • Flutter Web
  • printing: ^5.13.1
  • htmltopdfwidgets: ^1.0.3
  • pdf: ^3.11.1

Code snippet to reproduce the behavior:

import 'package:htmltopdfwidgets/htmltopdfwidgets.dart' as pdf;
import 'package:pdf/widgets.dart' as pw;
import 'package:printing/printing.dart';

// this is what I wrote in my code
await Printing.layoutPdf(
    onLayout: (format) async {
      final doc = pw.Document();
      final body = '<img src="$imageUrl" alt="qr"/>';
      final widgets = await pdf.HTMLToPdf().convert(body);

      doc.addPage(pw.Page(
        pageFormat: const pdf.PdfPageFormat(3420, 5700),
        build: (_) => widgets.first,
      ));

      return doc.save();
    },
);

Expected behavior
The browser opens a printing option to print the pdf.

Screenshots
As you can see in the video, when I tap on the print button, nothing seems to happen
https://github.com/user-attachments/assets/b70d6f66-ae82-4438-a285-372b6efcd52b

Flutter Doctor

[✓] Flutter (Channel stable, 3.24.1, on macOS 14.6.1 23G93 darwin-arm64, locale
    en-GB)
    • Flutter version 3.24.1 on channel stable at
      /Users/mingsern/fvm/versions/3.24.1
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5874a72aa4 (3 weeks ago), 2024-08-20 16:46:00 -0500
    • Engine revision c9b9d5780d
    • Dart version 3.5.1
    • DevTools version 2.37.2

[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/mingsern/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/to/macos-android-setup for more details.

[✗] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS
      and macOS development.
      Download at: https://developer.apple.com/xcode/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
    ✗ CocoaPods not installed.
        CocoaPods is a package manager for iOS or macOS platform code.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/to/platform-plugins
      For installation instructions, see
      https://guides.cocoapods.org/using/getting-started.html#installation

[✓] 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.93.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.96.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 14.6.1 23G93 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 128.0.6613.120

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

! Doctor found issues in 2 categories.

Desktop (please complete the following information):

  • iOS
  • Android
  • Browser
  • Windows
  • Linux

Smartphone (please complete the following information):

  • Device: [iPhone 12, iPhone 13]
  • OS: [iOS 17.6.1]
  • Browser: [Safari, Chrome]
  • Version: [N/A]

Additional context
There is a similar issue reported, 3 years ago, #640

@MingSern MingSern added bug Something isn't working needs triage labels Sep 8, 2024
Repository owner deleted a comment Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

1 participant