Skip to content

Layout issue when printing on IOS #1317

@shinxxxxwon

Description

@shinxxxxwon

Describe the bug
On Android, the layout is normal when printing, but on IOS, the layout is enlarged to create a PDF.

To Reproduce
Code snippet to reproduce the behavior:

///PdfPageFormat.a4
static const PdfPageFormat a4 =
      PdfPageFormat(2480, 3508);

///printing Method
_generatedPdf(PdfPageFormat format, BuildContext context, Size size, HttpCommunicate httpCommunicate) async {

    DrawScore drawScore = DrawScore();
    await drawScore.makePDF(context.read<PDFProvider>().uinPdfData!);

    // bool bRes = await Printing.layoutPdf(onLayout: (format) async => pdf.save());
    final output = await getTemporaryDirectory();
    final file = File('${output.path}/score.pdf');
    await Printing.layoutPdf(onLayout: (_) => file.readAsBytesSync());
  }

Expected behavior

image

Screenshots

Flutter Doctor

[✓] Flutter (Channel stable, 2.10.2, on macOS 13.2.1 22D68 darwin-arm, locale ko-KR)
    • Flutter version 2.10.2 at /Users/sinjeong-won/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 097d3313d8 (1년, 1달 전), 2022-02-18 19:33:08 -0600
    • Engine revision a83ed0e5e3
    • Dart version 2.16.1
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/sinjeong-won/Library/Android/sdk
    • Platform android-32, build-tools 32.1.0-rc1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2021.1)
    • 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 11.0.11+0-b60-7772763)

[✓] VS Code (version 1.76.2)
    • VS Code at /Users/sinjeong-won/iCloud Drive(아카이브)/Desktop/Visual Studio Code.app/Contents
    • Flutter extension version 3.60.0

[✓] VS Code (version 1.73.1)
    • VS Code at /Users/sinjeong-won/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.60.0

[✓] VS Code (version 1.76.2)
    • VS Code at /Users/sinjeong-won/iCloud Drive(아카이브) - 1/Desktop/Visual Studio Code.app/Contents
    • Flutter extension version 3.60.0

[✓] Connected device (3 available)
    • SM T510 (mobile)     • R54N100K7HW               • android-arm    • Android 11 (API 30)
    • 신정원의 iPhone (mobile) • 00008020-001C646C3601002E • ios            • iOS 15.5 19F77
    • Chrome (web)         • chrome                    • web-javascript • Google Chrome 111.0.5563.146

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Desktop (please complete the following information):

  • iOS
  • Android
  • Browser
  • Windows
  • Linux

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context

I used the print package on 'android' and 'ios'. In Android, it is normally created and printed according to the size specified in PdfPageFormat.a4 (2480 * 3508), but in IOS, PDF is created and printed out of layout as shown in the figure above. Is there a part that needs to be modified separately when printing on iOS?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleIssue marked for deletion

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions