我正在尝试这段代码:
PageSetupDialog pageSetupDialog = new PageSetupDialog();
pageSetupDialog.PageSettings = new PageSettings();
pageSetupDialog.PageSettings.PaperSize = new PaperSize("A5", width: 583, height: 827);
pageSetupDialog.ShowDialog();
但是在显示对话框后,默认的PaperSize是Letter。
有没有办法设置PageSetupDialog
的默认纸张尺寸?
答案 0 :(得分:1)
试试这个:
PrinterSettings printerSettings = new PrinterSettings();
IEnumerable<PaperSize> paperSizes = printerSettings.PaperSizes.Cast<PaperSize>();
PaperSize sizeA4 = paperSizes.First<PaperSize>(size => size.Kind == PaperKind.A4); // setting paper size to A4 size
PageSetupDialog pageSetupDialog = new PageSetupDialog();
pageSetupDialog.PageSettings = new PageSettings() { PaperSize = sizeA4 };