简体   繁体   中英

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?

Through the PrintDocument.DefaultPageSettings browsable property.

PrintDocument.DefaultPageSettings.Landscape = true;

So, for your code sample, this would be:

doc.DefaultPageSettings.Landscape = true;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM