我已经可以创建打印以在Windows窗体中打印文件。但是,每当我添加以下代码时:
printDialog.PrinterSettings.DefaultPageSettings.Landscape = true;
我看不到页面的方向变为LandScape,它仍然是纵向。
如何使它成为LandScape的默认值?因此,每当我单击PrintPreview或PrintFile时,页面的方向将变为LandScape,而不是纵向。
这是代码:
private void PrintPreview(object sender, EventArgs e)
{
PrintPreviewDialog _PrintPreview = new PrintPreviewDialog();
_PrintPreview.Document = printDocument1;
((Form)_PrintPreview).WindowState = FormWindowState.Maximized;
_PrintPreview.ShowDialog();
}
private void PrintFile(object sender, EventArgs e)
{
PrintDialog printDialog = new PrintDialog();
printDialog.Document = printDocument1;
printDialog.UseEXDialog = true;
if (DialogResult.OK == printDialog.ShowDialog())
{
printDocument1.DocumentName = "Test Page Print";
printDocument1.Print();
}
}
尝试Landscape
如下设置PrintDocument,
printDocument1.DefaultPageSettings.Landscape = true;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句