Here is the idea: you can know it, but you don't really need to tell "portrait" from "landscape". You only need to know the paper size, which you will always know from the page information. You need to know the size anyway, to render the printing graphics correctly.
You do all printing using the class
:
https://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument%28v=vs.110%29.aspx[
^].
Now, please look at the code sample and pay attention how the event
PrintPage
is handled. First of all, the instance of
PrintPageEventArgs
is passed to your handler. Look at this type:
https://msdn.microsoft.com/en-us/library/system.drawing.printing.printpageeventargs%28v=vs.110%29.aspx[
^].
As you can see, the event arguments include such data as
MarginBounds
and
PageBounds
. You can use this layout information to directly build the layout for the data rendered on print. But if you want, you still get the property
PrintPageEventArgs.PageSettings
. From this property, you know if this is "portrait" or "landscape":
https://msdn.microsoft.com/en-us/library/system.drawing.printing.printpageeventargs.pagesettings%28v=vs.110%29.aspx[
^],
https://msdn.microsoft.com/en-us/library/system.drawing.printing.pagesettings%28v=vs.110%29.aspx[
^].
That's all.
—SA