开发者

printing an image in landscape orientation?

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?


doc.DefaultPageSettings.Landscape = true;

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


Through the PrintDocument.DefaultPageSettings browsable property.

PrintDocument.DefaultPageSettings.Landscape = true;

So, for your code sample, this would be:

doc.DefaultPageSettings.Landscape = true;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜