
Hi,
We are using controls from Telerik UI for WinUI in our project. There is sales invoice report and generated PDF file of that report. We would like to show print dialog after processing the sales invoice. For this purpose we are using WinUI PdfViewer (RadPdfViewer control). The RadPdfViewer control shows content of PDF file, we are not able to print.
RadPdfViewer has Print() method. When we set DocumentSource as PDF file and call Print() method, should it show print dialog? See attached sample project, run and click "Print report" button. Nothing happen, but my expectation is showing print dialog. Any idea/solution to print pdf file?
1 Answer, 1 is accepted
Hi Tursunkhuja,
Indeed, the printing is not supported yet. We tried to implement it when developing the control, however due to framework limitations it was not possible to open Print dialog (check this issue). Looks like lately they have added it support, but it only works correctly on Win11, so we could implement it as well. I have created feature request for that, so you can track on the link below:
PdfViewer: Print file support (telerik.com)
Meanwhile I will check if I can suggest some custom solution and will get back to as soon as possible.
Thanks for understanding. Let me know if you have any other questions or concerns.
Regards,
Kalin
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hello Kalin,
Thank you for your response. As a workaround, did you find any custom solution?
Hi Tursunkhuja,
We investigated the scenario, however I am afraid that for the moment we cannot suggest a custom solution that would be supported on Windows 10. That said, we are currently looking into whether we can support the printing feature for Windows 11.
Would the Windows 11 support be suitable for your scenario?
Hi,
As a workaround, we are using WinUI reportviewer control to print. WinUI reportviewer uses Win32 printing. What will be benefits after supporting the printing for Windows 11?
Thanks,
Hello Tursunkhuja,
Using the ReportViewer to print the document is a viable approach for Windows 10.
We are looking into supporting the printing on Windows 11 natively through the WinUI API. We view this as a benefit, since we prefer going through the framework API whenever possible.
Of course, for the time being, you can stick to printing through the WinUI ReportViewer.
Hi,
I decided to use RadPdfViewer and it seems it shows Print dialog in Windows 10 as well. But the problem I have, is programmatically I need to know somehow if the user clicked Print button on Cancel button from the dialog. Do you have any solution to this? or any workaround?
Thanks!
We need to use printing Telerik reports. Users can print in windows 10 and windows 11. What is the solution for this which is independent from OS version?
Thanks!
I can confirm that the printing works also on my Windows 10 machine. Probably Microsoft made some improvements in the printing through the new WinUI version or maybe a Windows update. Can't tell, but we will check this further and update the help documentation, if this works properly on Windows 10 as well.
The print preview dialog we open is part of the printing API of WinUI and we don't have a direct access to it, so we don't have any methods to get the buttons and modify them or listen for their clicks. I also couldn't find any public API from the WinUI printing classes that allows this.
To create reports on different OS version, you can use the Telerik Reporting product. However, I am not sure what do you mean by a solution which is independent from the OS version. Do you mean that you want to use the ReportViewer control to print the reports on different versions of Windows OS or different OS version (Windows, Linux, Mac)? Also, do you need to use the ReportViewer to display the reports on the different OS versions or you only need to design, create and print them without displaying anything in the UI?
Hello, thanks for the answer,
For now, we use WinUI ReportViewer control to see & print the reports.
But, in some use cases we need to print a report without showing ReportVewier control, we want to see Print dialog. To show Print dialog we experienced ReportViewer (by calling Pring method) and RadPdfViewer control (by calling Pring method) which is showing Print dialog, but the only problem here is we need to somehow handle the print dialog to know if user pressed Print button or Cancel button. If it's not possible by those controls (ReportViewer, RadPdfViewer), it would be fine if you suggest any workaround or another solution.
FYI: We use WinUI ReportViewer in our client app which connect to Telerik Reporting Rest Service by giving connection string and report name. Report files are stored in the service side.
Thanks,
Thank you for the extra information.
I am afraid that at this point there is no workaround that I can suggest. The printing in both controls (PdfViewer and ReportView) is using some Windows APIs that are not providing means of customization at this point. This prevent us to add functionality (like events) for this exact requirement and also I can't suggest a proper customization.
An idea that you can explore is to research printing solutions (like more deep research on what the WinUI framework provides or any third party library for WinUI) and then instead of using the built-in printing support, you can introduce your own logic that shows custom dialog and prints the document accordingly.
Hi Martin,
It's important to know if Print dialog is closed or not. As you said, it's not Telerik control issue. Is there an issue reported to Microsoft about this issue (catching canceling Print dialog)? Can you send me that link?
Thanks,
Hey Tursunkhuja, I am not aware if there is something on the topic in the Microsoft official channels. I also couldn't find anything on the internet. What I can suggest you is to search through the Issues tab of the microsoft-ui-xaml repository and if there is nothing on your requirement, to post a new feature proposal.
Internally Telerik uses the PrintManager class from the Windows.Graphics.Printing namespace. This is part of the Micorsoft.Windows.SDK.NET package.