-
Notifications
You must be signed in to change notification settings - Fork 710
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
Question: Printing in WinUI 3 Desktop #4419
Comments
I agree that at least adding printing APIs to the roadmap would be very helpful to plan for WinUI 3.0 adoption. |
@MikeHillberg and @codendone do you have any insights here? |
Thank your for opening this issue. I myself planned to do it some time ago, but back then I was busy and I forgot about it. AFAIK, there is the interface IPrintManagerInterop which has the methods: |
If it is the intended default, I hope the API sees improvements to large document handling. Printing a 100+ page document quickly leads to out-of-memory scenarios in UWP as you need to render all the pages up front and in-memory in XAML before handing off to be printed. Some form of "on demand" callback would help work around that. |
I'm sorry, the PrintDocument API hasn't been updated for WinUI3 yet, and it's an accident that the API is showing up right now. I'll look into the roadmap, but it's not something we're actively working on yet. @JohnnyWestlake, you should be able to hand off a page at a time rather than all 100 at once. After each call to PrintDocument.AddPage you don't need the keep the |
Hi @MikeHillberg, do you have an update on where printing sits in the roadmap please. I really need to get some printed output from a Win UI 3 (Reunion 0.5) Desktop app and would appreciate guidance from the team please. Thanks |
Hi, any updates on this, or is there any workaround? At now we try to find a way to print documents in our application |
Hi @MikeHillberg, We are testing a port of an app from UWP to WinUI Desktop. PrintManager is also what we require too. It will be great to let us know what the future guidance for this is. Thanks. |
Windows App SDK is now 1.0 stable and this bug still prevents printing (and using PrintHelper from Community Toolkit). |
@MartinRothschink et al. You can vote on this and other things you want here: https://portal.productboard.com/winappsdk/1-windows-app-sdk/c/50-support-printmanager-api |
Thanks, voted. |
Still no updates? |
Working with WinUI and still waiting on PrintDocument to be updated to WinUI. |
same |
I made a test sample : WinUI3_Print.zip |
I have put in comments (at beginning of MainWindow.xaml.cs) the links to the 3 Assemblys to add, depending on .NET 6 version |
Could get it to work with your example @castorix, but with the PrintHelper from the Windows Community Toolkit, I still get the same error as the @bridgesquared |
Ok, I've got it working, but... these are old-style dialogs, which I do not really want in my WnUI3(!) app 😊 So I will rather wait, until the PrintManager is working, similarly to UWP apps. |
Getting System.ArgumentException: 'Value does not fall within the expected range.' |
The sample works for me on Windows 11 (21H2), but gives me the same |
Yes I'm on Windows 10 when I get this error. |
Nop. It should be working on Windows10 too. My team is investigating why these APIs don't work on Win10 given they were there since long time ago. Maybe there is some piece of the puzzle that we lost. |
had to change the first line, instead of using "this" i used "App.StartupWindow" var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(App.StartupWindow); At least the printUI does show up, but i got some problems with my dispatcher now... |
So I was trying to print with System.Windows.Forms.PrintDialog and when I try to render a UIElement (page to print) to bitmap with RenderTargetBitmap I get the same error : Value does not fall within the expected range, in renderBitmap.GetPixelsAsync(). |
@Redp87 @NoI3ody @FreddyD-GH It looks like there is a bug in Windows 10 (internal link) that's preventing the IPrintManagerInterop solution from working. We're investigating servicing the fix downlevel, and will update here when we know more about that. |
And following @krschau comments - Given the OS service updates process, I don't expect we can make it before September 2022. |
@marb2000 Thanks, that info is very helpful for planning. |
I ended up going with the method of creating an HTML document template that resembles a word document then modifying it using HTML agility pack and then opening it in Webview2 and calling the print function. The best part about this approach is that it also works on .net MAUI. |
Any Updates? |
Hi. Any solutions ? Thanks |
@marb2000 & @krschau
|
Sounds like this might be (finally) coming to Windows 10 in 19045.2788, which is currently in preview. I have not tested printing there yet, but it is mentioned in the release notes and also here
-- |
I tested in windows10(19045.2846,22H2). It show print preview dialog. |
Is this issue still open? Any updates on this? |
Printing doesn't work with I'm trying to look if it's a capability missing, but no clue as of now because no exception or error are happening. Edit
|
I get the same error. Summarising the previous comment - it looks like printing is not possible in WinUI 3 desktop apps today unless they are also declare |
I realize that few people still print to paper, but many of us need the ability to print to PDF or the like. |
@DaveAurionix I wouldn't consider it a workaround but an overall better solution than to use the built in printer is to use WebView2 and HTMLAgilityPack to make HTML printouts, they're instant to load and work cross platform on any app framework. |
I cannot believe this is an issue, especially for this long. WinUI will never be able to compete with WinForms for business applications if you cannot print a SfDataGrid, for example. Our progress on our application just came to a complete stop thanks to this. |
In desktop apps, any control can be printed (PrintManager or Win32 methods (GDI, GDI+, Direct2D)) |
Hi all
I'm looking for guidance on printing from WinUI 3 Desktop please.
I tried the
PrintHelper
from Community Toolkit 8 preview 4 and get aSystem.Runtime.InteropServices.COMException: 'Interface not registered (0x80040155)'
I put this down to issues with getting theWindows.Graphics.Printing.PrintManager
as reported in #4375 and #4363.So I suppose I'm trying to answer a few questions:
I would welcome any thoughts, pointers etc. please. I know there's a huge amount of working going on to get the controls working properly, but Print has just got to the top of my stack and I'm a bit worried that it has fallen through the cracks which is going to cause issues as I can't ship without it.
BTW. We do have some fallback ideas, maybe WebView HTML generation or PDF generation, but to be honest I rather liked the UWP approach to printing and really hope it makes it through to WinUI 3 Desktop.
Thanks for your time, and all your hard work. I do think this unified approach is the right way to go and I can't wait to get away from NET Native and shipping modern apps with up-to-date backing tech (NET5/6 + WinUI)
The text was updated successfully, but these errors were encountered: