DavBfr / dart_pdf

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

[printing] No Windows desktop support #696

Closed mrverdant13 closed 3 years ago

mrverdant13 commented 3 years ago

Describe the bug

On Windows, the Printing.layoutPdf util does not show up the printing dialog.

It does not even show any error/exception.

To Reproduce

In a button callback and with an existing assets/files/document.pdf file.

print('Printing...');

try {
    final pdf = await rootBundle.load(
        'assets/files/document.pdf',
    );

    print('File size: ${pdf.lengthInBytes}');

    final printed = await Printing.layoutPdf(
      onLayout: (_) => pdf.buffer.asUint8List(),
    );

    print('Printed: $printed');
} catch (e) {
    print(e.runtimeType);
}

Expected behavior

The printing dialog is expected to be shown or, at least, an identifiable exception should be thrown.

Screenshots

No error message and no dialog: image

Flutter Doctor

Flutter Doctor output ``` [√] Flutter (Channel stable, 2.0.3, on Microsoft Windows [Version 10.0.19041.985], locale en-US) • Flutter version 2.0.3 at C:\flutter • Framework revision 4d7946a68d (9 weeks ago), 2021-03-18 17:24:33 -0700 • Engine revision 3459eb2436 • Dart version 2.12.2 [√] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at C:\Users\karlo\AppData\Local\Android\sdk • Platform android-30, build-tools 30.0.2 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.9.6) • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community • Visual Studio Community 2019 version 16.9.31313.79 • Windows 10 SDK version 10.0.19041.0 [√] Android Studio (version 4.1.0) • Android Studio at C:\Program Files\Android\Android Studio • 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 1.8.0_242-release-1644-b01) [√] VS Code (version 1.56.2) • VS Code at C:\Users\karlo\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.22.0 [√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19041.985] • Chrome (web) • chrome • web-javascript • Google Chrome 90.0.4430.212 • Edge (web) • edge • web-javascript • Microsoft Edge 90.0.818.62 • No issues found! ```

Platform:

Additional context

Printing version: printing: ^5.2.1

I already checked the Windows ffi implementation but might take a while for me to fix this issue. If you have any suggestions or insights, I'd be glad to read/hear from you so I can make a PR.

mrverdant13 commented 3 years ago

After understanding Windows embedding and after noticing that the main (with the version 5.3.0) branch of this repo already solves this issue, closing this issue.

Solution until next release:

  printing:
    git:
      url: git://github.com/DavBfr/dart_pdf.git # 5.3.0 as of now
      path: printing