private void OnPageSetup(object sender, EventArgs e) { PageSetupDialog.Document = Document; PageSetupDialog.PrinterSettings = Document.PrinterSettings; PageSetupDialog.ShowDialog(); Document.PrinterSettings = PageSetupDialog.PrinterSettings; NumPages = 0; PreviewControl.InvalidatePreview(); }