Pergunta

I want to print the currently active WinForm in C#. Here is what I have:

using Microsoft.VisualBasic.PowerPacks.Printing;

PrintForm p = new PrintForm(this);
p.Print();

This works great for portrait mode. How can I print in landscape mode?

Foi útil?

Solução

Does this work?

PrintForm p = new PrintForm(this);
p.PrinterSettings.DefaultPageSettings.Landscape = true;
p.Print();

Outras dicas

if you are doing this in VB then you want to look at Orientation as an example

if it's C# I am sure you can do the conversion

If p.Height > p.Width 
{
    p.Orientation = 1;//vbPRORPortrait
}
Else
{
    p.Orientation = 2; //vbPRORLandscape
}
p.Print();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top