-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Description
After the Windows 22H2 update, it seems that the modern UWP print dialog is used when trying to print XPS documents from a WPF application. This new dialog does not respect print settings that are set programmatically in the PrintTicket, such as page orientation.
Reproduction Steps
See sample repo here
Minimal repro code:
private void Print()
{
var localPrintServer = new LocalPrintServer();
var printQueue = localPrintServer.DefaultPrintQueue;
var printTicket = printQueue.DefaultPrintTicket;
printTicket.PageOrientation = PageOrientation.Landscape;
var dialog = new PrintDialog
{
PageRangeSelection = PageRangeSelection.AllPages,
UserPageRangeEnabled = false,
PrintQueue = printQueue
};
dialog.PrintTicket = dialog.PrintQueue.MergeAndValidatePrintTicket(dialog.PrintQueue.DefaultPrintTicket, printTicket).ValidatedPrintTicket;
var allowPrint = dialog.ShowDialog().Value;
if (allowPrint)
{
var xpsDocumentWriter = PrintQueue.CreateXpsDocumentWriter(printQueue);
xpsDocumentWriter.Write(CreateSomeContent(), dialog.PrintTicket);
}
}Expected behavior
Print dialog should show landscape orientation when the printTicket page orientation is set to PageOrientation.Landscape
Actual behavior
Print dialog should show Landscape paper orientation when print ticket setting is set to landscape.
Regression?
Previous versions of Windows 10 show the legacy print dialog by default instead of the UWP dialog.
Known Workarounds
Registry key modification to disable UWP dialog
Impact
WPF application using print dialogs are not able to show preview or set printer settings. Additionally, printer settings are not remembered after dialog use.
Configuration
-
Which version of .NET is the code running on?
Tried: .Net Framework 4.8.1 and .Net 6 -
What OS and version, and what distro if applicable?
Windows 11 22H2 -
What is the architecture (x64, x86, ARM, ARM64)?
x64 -
Do you know whether it is specific to that configuration?
Appears to work in Windows 10 with old dialog. Also works in VMs (since the new UWP dialog does not get used in VMs)
Other information
- Posting here in case there's a suggestion. Please advice if it should be a different repo and happy to adjust as needed.
- Stackoverflow post