以横向打印图像?

时间:2010-11-09 19:16:34

标签: c# .net winforms printing

我正在将控件转换为位图并将其打印出来:

using (MemoryStream ms = new MemoryStream())
{
    chart1.SaveImage(ms, ChartImageFormat.Bmp);
    Bitmap bm = new Bitmap(ms);

    PrintDocument doc = new PrintDocument();
    doc.PrintPage += (s, ev) =>
    {
        ev.Graphics.DrawImage(bm, Point.Empty); // adjust this to put the image elsewhere
        ev.HasMorePages = false;
    };

    doc.Print();
}

如何指定以横向打印?

2 个答案:

答案 0 :(得分:12)

答案 1 :(得分:4)

通过PrintDocument.DefaultPageSettings可浏览的属性。

PrintDocument.DefaultPageSettings.Landscape = true;

因此,对于您的代码示例,这将是:

doc.DefaultPageSettings.Landscape = true;