I am trying to make a Print application on UWP, but the samples show
await Windows.Graphics.Printing.PrintManager.ShowPrintUIAsync();
This
I am using RawPrint nuget to print silently in UWP:
https://github.com/frogmorecs/RawPrint
Sample:
...
if (file != null)
{
IPrinter printer = new Printer();
var stream = await file.OpenStreamForReadAsync();
printer.PrintRawStream("Brother DCP-L2540DN series Printer", stream, file.DisplayName);
}
await Windows.Graphics.Printing.PrintManager.PrintAsync();
As far as I know, there is no such api for printer without PrintUI
. And I search some similar issues. And the answer is negative. If you do want this feature, you are welcome to vote up on the UserVoice .
The current UWP API does not support silent printing, i.e. without explicit user interaction.
For POS scenarios UWP does offer the POSPrinter API - this may or may not apply to your scenario though:
https://docs.microsoft.com/en-us/uwp/api/Windows.Devices.PointOfService.PosPrinter
https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/PosPrinter
For LOB applications running on desktop, you also have the option to continue using your Win32 printing APIs from a fulltrust process included in your UWP app package. I have put together a quick sample that demonstrates this technique in the example of printing image files silently from a UWP:
Store: https://www.microsoft.com/store/apps/9pd51nnkx3t2
Source: https://1drv.ms/u/s!AovTwKUMywTNnOsbzlRfghOikDy8Dw
It's certainly a valid feature request and we should extend the API to enable this scenario with the right user model in place (API, capability, settings, etc.) to ensure a proper user experience.
Please vote here on UserVoice to help the team prioritize the feature: https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/6185763-allow-direct-printing-without-modern-ui-print-dial