将打印方向设置为横向

将打印方向设置为横向

本文介绍了将打印方向设置为横向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经可以在Windows窗体中创建打印文件来打印文件了.但是,每当我添加此代码时:

i already can create a print to print a file in my windows forms. However, whenever i add this code:

printDialog.PrinterSettings.DefaultPageSettings.Landscape = true;

我看不到页面的方向变为LandScape,它仍然是纵向.

I can't see the Orientation of the page become LandScape, it is still Portrait.

如何将其默认设置为LandScape?因此,每当我单击PrintPreview或PrintFile时,页面的方向将变为LandScape,而不是纵向.

How do I make it LandScape as default? So, whenever i click PrintPreview or PrintFile, the Orientation of the page will become LandScape, not Portrait.

这是代码:

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();
    }
}

推荐答案

尝试如下设置PrintDocument的 Landscape

try setting the Landscape of PrintDocument as follows,

printDocument1.DefaultPageSettings.Landscape = true;

这篇关于将打印方向设置为横向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 21:23