-
-
Notifications
You must be signed in to change notification settings - Fork 585
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 desktop #9
Comments
Are you talking about https://github.com/google/flutter-desktop-embedding ? |
Hey @DavBfr EDIT: |
@gedw99, any update on this issue? |
hey @DavBfr Not yet ! Just had an issue with IOS and printing :) |
Has this stalled? |
Hello, any news about this? |
Do we have a stable plugin api now for desktop-shells? I think MacOS and Linux should be easy to do using cups. But Windows will require a conversion from PDF to native print. |
Could you give me a light on how to do this? I need it to work at least on windows |
The most simple way to print a pdf on windows would be to generate the pdf, save it on a temporary folder and print using sumatrapdf as an external command line. |
Great, I'll study it better, thank you very much |
Here is a dart code using FFI to list the printers on a Windows machine. import 'dart:convert';
import 'dart:ffi' as ffi;
typedef CEnumPrinters = ffi.Int32 Function(
ffi.Int32 flags,
ffi.Pointer<ffi.Uint8> name,
ffi.Int32 level,
ffi.Pointer<ffi.Uint8> printerEnum,
ffi.Int32 buf,
ffi.Pointer<ffi.Int32> needed,
ffi.Pointer<ffi.Int32> returned,
);
typedef EnumPrinters = int Function(
int flags,
ffi.Pointer<ffi.Uint8> name,
int level,
ffi.Pointer<ffi.Uint8> printerEnum,
int buf,
ffi.Pointer<ffi.Int32> needed,
ffi.Pointer<ffi.Int32> returned,
);
// Example of handling a simple C struct
class PrintInfo extends ffi.Struct<PrintInfo> {
@ffi.Int32()
int flags;
@ffi.Uint64()
int _description;
@ffi.Uint64()
int _name;
@ffi.Uint64()
int _comment;
String _utf16ToString(int address) {
final ptr = ffi.Pointer<ffi.Uint16>.fromAddress(address);
final units = List<int>();
var len = 0;
while (true) {
final char = ptr.elementAt(len++).load<int>();
if (char == 0) break;
units.add(char);
}
return Utf8Decoder().convert(units);
}
String get description => _utf16ToString(_description);
String get name => _utf16ToString(_name);
String get comment => _utf16ToString(_comment);
@override
String toString() =>
'$runtimeType\n Flags=$flags\n Name=$name\n Description=$description\n Comment=$comment';
}
void main() {
final dylib = ffi.DynamicLibrary.open('winspool.drv');
final enumPrintersPointer =
dylib.lookup<ffi.NativeFunction<CEnumPrinters>>('EnumPrintersW');
final enumPrinters = enumPrintersPointer.asFunction<EnumPrinters>();
final needed = ffi.Pointer<ffi.Int32>.allocate()..store(0);
final returned = ffi.Pointer<ffi.Int32>.allocate()..store(0);
enumPrinters(2, ffi.Pointer.fromAddress(0), 1, ffi.Pointer.fromAddress(0), 0,
needed, returned);
final bufferSize = needed.load<int>();
final buffer = ffi.Pointer<ffi.Uint8>.allocate(count: bufferSize);
final result = enumPrinters(
2, ffi.Pointer.fromAddress(0), 1, buffer, bufferSize, needed, returned);
if (result == 0) throw ('Error listing the printers');
final count = returned.load<int>();
final a = ffi.Pointer<PrintInfo>.fromAddress(buffer.address);
for (int i = 0; i < count; i++) {
print(a.elementAt(i).load<PrintInfo>());
}
buffer.free();
} |
macOS desktop support is fully implemented in printing 3.0.0 |
It's been long time with no activity on this issue. Anyone working on getting windows support for printing ? please share the progress so that we can make this plugin cross-platform. |
Here is a branch with a windows plugin, if some C++ / windows experts want to help. https://github.com/DavBfr/dart_pdf/tree/windows The goal is to use Pdfium for the rendering and share as much code as possible with the Linux implementation, which is not the case yet. |
Thanks for the update @DavBfr . I will try to work on C++ part, although I am not a windows expert. This plugin is very essential to make cross-platform apps. |
@DavBfr did you take a look at https://pub.dev/packages/windows_printing Any learnings from this plugin implementation. |
@viveknimkarde yes I saw it, but it's really limited. |
That's just great @DavBfr. I will test few use cases and we can get in out in next release. |
Here you are: printing version 3.7.0 has Windows Desktop support, for x64 builds. It's beta quality for now, full of memory leaks and missing bits, but the feature is there. |
Hey @DavBfr thanks for your work. My problem is that I am using thermal printer for print billing receipt but it always print blank receipts. Any help would be appreciated.. |
I am printing simple hello world but it does not print anything.
|
Look at the windows CPP code. And adapt to your situation. I don't have a thermal printer. |
Sir I dont understand anything can you guide me plzz how to solve this problem. |
Hey @DavBfr can you please tell me what kind of problem i am facing right now..?? |
@rizirf-connect I don't know. Please share more code. |
@DavBfr sir I am using all this code to simply print hello world in my thermal printer, but It is printing blank paper. |
Closing this issue as #468 is the last OS to support. |
This is a very ambitious issue.
There is no reason this can't work on desktop. The plugins can be replaced with windows and Mac equivalents and it should work.
The text was updated successfully, but these errors were encountered: