2

I have a requirement to print PDF on the printer from the Flutter app. Is there a chance to have a possibility to do so right now? I mean that my application is going to fetch the PDF file from the server and then I would like to put it directly to the printer, so it can be printed instantly. The platform that I am targetting is windows.

If this is not possible then is there a chance to execute .bat script using flutter? In the case that there would be no such possibility I could make the script that would print expected file to avoid flutter in this functionality

Patryk Jabłoński
  • 697
  • 10
  • 29
  • If it is web flutter it would be possible in flutter desktop I have not tried it. – DomingoMG Aug 20 '19 at 18:09
  • I am implementing the desktop application, so it is not web :( – Patryk Jabłoński Aug 20 '19 at 18:11
  • Try to add: import 'dart:html'; and later onTap button: window.print("http://www.example.com/example.pdf"); I don't know if it works, but try. – DomingoMG Aug 20 '19 at 18:14
  • 2
    you'll have to write the windows code for that and communicate with it using `MethodChannel` – Ryosuke Aug 20 '19 at 18:15
  • @Ryosuke I understand, so I have to modify the Windows project with the custom method to print proper file. Seems to be a thing that will work. Thanks for the suggestion – Patryk Jabłoński Aug 20 '19 at 18:16
  • yeah right now its the only way. unfortunately I wasn't able to find any Windows plugin example. Maybe it's similar to linux that's why they didn't provide it. – Ryosuke Aug 20 '19 at 18:21
  • 1
    You could also try [go-flutter-desktop](https://github.com/go-flutter-desktop/go-flutter), write the plugin with *go* may be a good option! – Tokenyet Aug 20 '19 at 19:13
  • You can try with [flutter-printing](https://pub.dev/packages/printing) – Dharmesh Fumakiya Aug 20 '19 at 20:50
  • 1
    is there a chance to execute .bat script using flutter? Yes. You can. please see my post to start Excel with Process.run https://stackoverflow.com/questions/56143104/flutter-desktop-go-flutter-desktop-open-excel-file-on-windows-platform – chunhunghan Aug 21 '19 at 01:50
  • with Process.run and this https://www.robvanderwoude.com/printfiles.php#PrintPDF , it might work. – chunhunghan Aug 21 '19 at 01:51
  • I contribute go-flutter plugin, for me, I will write a C# program and install in disk or try to make this C# print as web api and call this web api (,I do not know is it work on web api ) – chunhunghan Aug 21 '19 at 01:56
  • I am sorry about my spamming. It's possible to do remote printing. https://www.strathweb.com/2012/10/remote-printing-with-asp-net-web-api-in-windows-service/ – chunhunghan Aug 21 '19 at 02:02
  • @Ryosuke https://github.com/google/flutter-desktop-embedding/tree/master/plugins/example_plugin has a Windows implementation. – smorgan Aug 21 '19 at 05:02
  • @Dharmesh That's a plugin; existing Flutter plugins won't work on desktop without porting. See http://flutter.dev/desktop#plugins – smorgan Aug 21 '19 at 05:05

2 Answers2

0

Printing support is something you would likely want to implement with a plugin.

smorgan
  • 20,228
  • 3
  • 47
  • 55
  • The project structure of Flutter for desktop has changed substantially in the last year and a half. I've replaced the answer with the current link. – smorgan Feb 18 '21 at 13:00
0

You can try Printing Package ANDROID IOS LINUX MACOS WEB WINDOWS

exceptionsAreBad
  • 573
  • 2
  • 5
  • 17