printing an image in landscape orientation?

早过忘川 提交于 2019-12-23 09:34:44

问题


I am converting a control to a bitmap and print it:

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

How can you specify to print it in landscape orientation?


回答1:


doc.DefaultPageSettings.Landscape = true;

http://msdn.microsoft.com/en-us/library/system.drawing.printing.pagesettings.landscape.aspx




回答2:


Through the PrintDocument.DefaultPageSettings browsable property.

PrintDocument.DefaultPageSettings.Landscape = true;

So, for your code sample, this would be:

doc.DefaultPageSettings.Landscape = true;


来源:https://stackoverflow.com/questions/4137507/printing-an-image-in-landscape-orientation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!