Restrict printer selection while printing in WinUI app

Navaneeth 21 Reputation points
2025-01-24T10:24:43.7566667+00:00

In a WinUI app, I want to restrict the user from selecting any printer, only allowing a predefined set of printers. Additionally, the user should not be able to modify the print settings, such as altering the paper size or page range; they should only be able to select the printer and initiate printing.

How can I achieve this using the PrintManager, PrintTask and PrintDocument APIs? Or is there any other alternatives to achieve this?

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
814 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,716 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 86,511 Reputation points
    2025-01-24T11:12:40.6233333+00:00

    Or is there any other alternatives to achieve this?

    A way is with ID2D1PrintControl.

    I uploaded a test sample recently, which can be improved : WinUI3_Direct2D_Print

    (I used RenderTargetBitmap to print an image of some controls, but you can print/draw anything inside BeginDraw/EndDraw of m_pD2DDeviceContext)

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.