WindowsAppSDK icon indicating copy to clipboard operation
WindowsAppSDK copied to clipboard

Proposal: Allow the App to Print without showing the Confirmation Dialog to user

Open TonyHenrique opened this issue 4 years ago • 45 comments

Proposal: Allow the App to Print without showing the Confirmation Dialog to user

Summary

We should be able to programatically list printers, select the printer, configure paper size, orientation, settings... and PRINT without user interaction.

Rationale

I was trying to make a Touch Screen Kiosk Receipt Print application on UWP, but the samples show

await Windows.Graphics.Printing.PrintManager.ShowPrintUIAsync(); This brings the UWP Print Dialog.

I need to print directly without this dialog. How to do this?

I need something like

await Windows.Graphics.Printing.PrintManager.PrintAsync(); We should be able to programatically list printers, select the printer, configure paper size, orientation, settings...

This will enable:

  • Enable easy printing from Voice / Touch applications
  • Make the printing API more complete, like the WPF Printing API was.
  • This Permission will be very useful for ATM Applications, Touch Screen Kiosk Apps, Barcode Printing Software, Point of Sale applications, Line-of-Business Applications, etc;

Scope

Capability Priority
This proposal will allow developers Print without user interaction. Must
This proposal will allow the App to Configure Paper Size Must
This proposal will allow the App to Set Page Orientation Must
This proposal will allow the App to List printers Must
This proposal will allow end users to give the Printing without interaction permission on app install (AllowPrintingWithoutUserIteraction) Should
This proposal will allow the App to Change the Default Printer Could
This proposal will allow the App to set Printing Settings like Color, Grayscale, Draft Could

Important Notes

This may require the creation of a new permission/capability for UWP AppModel: AllowPrintingWithoutUserIteraction

Open Questions

TonyHenrique avatar Mar 18 '20 00:03 TonyHenrique

A separate capability for this would be good because it makes it clear that this is a special scenario, should be treated differently, and is probably not for everybody.

Even with this setting/capability I still think there's value in the user having to opt-in to silent printing through the UI once. This will avoid any app from surprising users by printing without ever showing any UI indicating that it wants to print. This would be comparable with requesting location or other potentially sensitive information that the user may not want.

This should also be an app level setting that can be revoked in future if the user desires.

For scenarios like kiosks that need to print and not desktop style apps that are more likely to be used by a single person for longer, such devices/apps still need initial configuration which would include testing the printer configuration and therefore enabling this setting.

mrlacey avatar Mar 18 '20 11:03 mrlacey

It could be a permission that only presents it's permission dialog on the first programmatic print - rather than just at install, or first run of the app.

mdtauk avatar Mar 18 '20 11:03 mdtauk

I suppose that this will be useful to enable to use Windows10X with UWP instead of Win32, for those scenarios.

I also sent a message about this to Stefan Wick, he said: ... Not a WinUI limitation, but a limitation of the appmodel you chose. When you build a WinUI app with Win32 appmodel it will work, but not with UWP appmodel. https://twitter.com/StefanWickDev/status/1240099309204287488

But anyways, I believe that the WinUI team can redirect this request, as this is required to increase the success of the WinUI, allowing it to be used in more scenarios, like the ones that I described.

TonyHenrique avatar Mar 18 '20 11:03 TonyHenrique

@TonyHenrique IMO you are correct in posting this issue here even if it's not directly WinUI related. There is just no other platform out there right now to discuss UWP app model/WinRT improvements and where we can be confident at least someone from MS will take a look at it and redirect it internally if required (yes, MS keeps repeating they listen to feedback even in the feedback hub but the perception of the feedback hub among the community is really bad). The WinUI team recognizes this feedback platform issue and thus tolerates community input discussing (fundamental) UWP issues.

Felix-Dev avatar Mar 18 '20 12:03 Felix-Dev

I know this is further out of scope, but it may be worth looking at a possible opt in permission system for WinUI Desktop. Giving the user peace of mind, without the Win32 free for all, and less restrictive than UWP.

Either creating new sets of permissable actions, or a way to detect if an action could be abused, and display a general "Are you sure you want to do XXXX" permission. With Just Once Always and Never options.

mdtauk avatar Mar 18 '20 12:03 mdtauk

@takashi-moriyama as FYI

ranjeshj avatar Mar 24 '20 14:03 ranjeshj

This is very similar to existing issue #52, but has more detail. @awsomecode would you mind if we made this the primary since it has the "proposal" format with details? What else would you want to add to the proposal?

jonwis avatar Jul 21 '20 17:07 jonwis

@jonwis Ya, this one will cover my requirement as well. You can make this primary.

AwsomeCode avatar Jul 21 '20 17:07 AwsomeCode

@TonyHenrique FYI we do not show consent prompts on install[1]; we show them on first-use (more correctly: the first time the app requests the permission, which might be before it actually "uses" it, depending on how the app is written and the specific API in question). Otherwise, agreed that this feature would need a permission that the user could consents to and can later change their mind in Settings.

[1] We do perform a UAC prompt for anything that impacts the machine / other users during install.

ptorr-msft avatar Jul 21 '20 18:07 ptorr-msft

Moving to backlog for future potential feature work.

stevewri avatar Sep 28 '20 19:09 stevewri

@stevewri This wont be available on WinUI3 ?

AwsomeCode avatar Oct 10 '20 00:10 AwsomeCode

This wont be available on WinUI3 ?

Printing without confirmation requires work at the security / isolation level, not just the UI level.

ptorr-msft avatar Oct 12 '20 01:10 ptorr-msft

This is so much import for retail softwares. Without this we can't convert WPF apps to UWP/WinUI3

AwsomeCode avatar Oct 16 '20 07:10 AwsomeCode

@AwsomeCode You should be able to print without a UI confirmation dialog if you will port your WPF apps to WinUI 3 desktop apps. @ptorr-msft's comment is about (WinUI 3) UWP apps (since the requested change will require changes in the UWP app model implementation and that's not something WinUI is responsible for).

Felix-Dev avatar Oct 16 '20 09:10 Felix-Dev

I'm trying to build a POS application with UWP, can't get the POS to recognize the cheaper thermal printers out there, I'm waiting on this to be realeased so I can properly deal with the printers that are not supported by the POS namespace.

elielson-anjos avatar Oct 19 '20 20:10 elielson-anjos

@Rothanan can you share the details of the printers that don't work? Are they specifically sold as POS devices that adhere to the POS standards?

ptorr-msft avatar Oct 20 '20 16:10 ptorr-msft

@ptorr-msft this are the few I have tried. https://www.atpos.in/product/atpos-usb-bluetooth-e-200-portable-thermal-receipt-printer/ https://www.atpos.in/product/atpos-hop-h58-58mm-thermal-receipt-printer/

Surprisingly they work with Android. But not with UWP.

AwsomeCode avatar Oct 21 '20 09:10 AwsomeCode

I wonder how macOS deal with such issue. Is there a "print permission", or apps are allowed to print without confirm?

ysc3839 avatar Oct 21 '20 10:10 ysc3839

@ptorr-msft they are very basic printers, they only work through ESC/POS. I can get them working on android, but not in UWP:

Here's a model: https://www.amazon.com/Wireless-Bluetooth-MUNBYN-Portable-Compatible/dp/B07N86DR4J

They are sold mainly as mobile bluetooth thermal printers(they also come with an usb conection) and because they are cheaper most customers wanna buy and use them.

elielson-anjos avatar Oct 21 '20 11:10 elielson-anjos

POS printers, sounds like an IOT device situation, and that supports device drivers right? Which would allow direct talking to the printer device right?

mdtauk avatar Oct 21 '20 11:10 mdtauk

Yeah, you're right, in android devices, all I do is send ESC/POS commands directly to the printer.

I'm looking for a way to do the same in UWP, in a Desktop environment.

elielson-anjos avatar Oct 21 '20 16:10 elielson-anjos

@Rothanan thanks for the info; I will send to the POS team internally to see if they know of any issues with these devices.

ptorr-msft avatar Oct 21 '20 21:10 ptorr-msft

@ptorr-msft any update from pos team?

AwsomeCode avatar Oct 27 '20 20:10 AwsomeCode

Sorry @AwsomeCode , some rather urgent personal stuff came up and I've been distracted. Tracking them down now and will pass along. Thanks for the reminder.

ptorr-msft avatar Oct 27 '20 21:10 ptorr-msft

Sorry to bother, but, any news on this?

elielson-anjos avatar Nov 01 '20 11:11 elielson-anjos

Can you confirm if you are using the POS APIs or the regular printing APIs?

ptorr-msft avatar Nov 03 '20 04:11 ptorr-msft

In UWP Its not POS APIs or Regular Printing API. I have tried RawPrint Which sends RAW ESC/POS data commands to printer and it print silently on printer. It works in debug mode. But on published app its not allowed. For published app we have to use Desktop Extension for UWP. Which is not best experience in development. (Our UWP app never get approved in store. They say its crashing and In our machines its working fine.)

In Android Sending RAW ESC/POS data commands via Bluetooth and its gets print silently.

In iOS Printer is not getting connected via Bluetooth.

Below are the printers I am referring to. https://www.atpos.in/product/atpos-usb-bluetooth-e-200-portable-thermal-receipt-printer/ https://www.atpos.in/product/atpos-hop-h58-58mm-thermal-receipt-printer/

AwsomeCode avatar Nov 03 '20 06:11 AwsomeCode

I have tried RawPrint Which sends RAW ESC/POS data commands to printer and it print silently on printer. It works in debug mode. But on published app its not allowed.

That project says it relies on .NET 4, which isn't supported for UWP apps (only .NET Native is supported). Can you pair the printers first and then use the POS API?

ptorr-msft avatar Nov 03 '20 06:11 ptorr-msft

I have tried this sample project it did not worked. https://docs.microsoft.com/en-us/samples/microsoft/windows-universal-samples/posprinter/

AwsomeCode avatar Nov 03 '20 07:11 AwsomeCode

Can you confirm if you are using the POS APIs or the regular printing APIs?

I tried using the POS API, it doesn't recognize the ESC/POS printer, the POS API support very few printers which renders it unusable.

We are just looking for a away to send ESC/POS commands to ANY printer that understands it.

elielson-anjos avatar Nov 03 '20 11:11 elielson-anjos