There is no big science to it, but thanks to a “bad choice of title”, the appropriate MSDN-KB-HOWTO article is not easy to find. So, here’s a link:
The above link takes you directly to the code snippet that sets print orientation to landscape; to change the orientation to portrait, you only need to change the DMORIENT_LANDSCAPE to DMORIENT_PORTRAIT; of course, the easiest way is to change the function to allow user to choose the orientation.
Note: The presented code, of course, also changes the orientation of the print preview.
To use the above code, simply surround your printing (or print preview) code with (provided you changed the function to accept bool to choose orientation, and to return previous setting):
CMyApp* app = (CMyApp*) ::AfxGetApp(); bool old_po = app->SetPrintOrientation(*your choice of orientation*); // printing (or print preview) code comes here app->SetPrintOrientation(old_po);
Note: So far, I didn’t manage to find a way to change the print orientation for individual pages; seems like you have to print portrait and landscape oriented pages in separate print jobs (?).