question

frankborty-4906 avatar image
0 Votes"
frankborty-4906 asked Viorel-1 edited

Orientation and Paper on Print Setup dialog

Working to a WPF Application (.NET fw 4.5), I can't find a way to display a print setup dialog as in the following image (I think it's based on Windows Forms but a WPF solution it would be better):

213043-image.png

Using the code:

 PrintDialog myPrintDialog = new PrintDialog();
 myPrintDialog.ShowDialog();

I obtain a dialog with Print Range and Copies Settings (which I don't need) but not Paper and Orientation (which I want to get).

I read the question wpfcsharp-print-dialog-settings but I can't figure out how to use the accepted answer.


dotnet-csharpwindows-wpfwindows-forms
image.png (39.8 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


In the standard dialog, if you press Properties, you can select the paper size and orientation. Maybe such behaviour is acceptable.


0 Votes 0 ·

1 Answer

Castorix31 avatar image
1 Vote"
Castorix31 answered Castorix31 commented

You can get it, but it is the old Dialog Box, replaced by PageSetupDialog as MSDN says at : print-dialog-box
For the PageSetupDialog, you can do for example :

             System.Windows.Forms.PageSetupDialog PageSetupDialog1 = new System.Windows.Forms.PageSetupDialog();
             PageSetupDialog1.PageSettings = new System.Drawing.Printing.PageSettings();
             PageSetupDialog1.PrinterSettings = new System.Drawing.Printing.PrinterSettings();
             PageSetupDialog1.AllowOrientation = true;
             PageSetupDialog1.AllowPaper = true;
             PageSetupDialog1.AllowPrinter = true;
             DialogResult result = PageSetupDialog1.ShowDialog();


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank for the hint but PageSetupDialog is not what I was searching for because doesn't allow the user to select the printer at runtime. Probably the best way is to create my own print setup dialog.

0 Votes 0 ·
Castorix31 avatar image Castorix31 frankborty-4906 ·

As the doc says, if I do a quick test with PrintDlg and PD_PRINTSETUP flag, I get this old dialog Box.
Test on french OS (Windows 10 21H1) :


213363-printdlg.jpg


0 Votes 0 ·
printdlg.jpg (134.8 KiB)