As you did, override OnPrepareDC and use following code.

if (pDC->IsPrinting())

{

CPrintDialog *pPD = pInfo->m_pPD;

DEVMODE *pDM = pPD->GetDevMode();

if (pDM->dmOrientation != DMORIENT_PORTRAIT)

{

pDM->dmOrientation = DMORIENT_PORTRAIT;

pDC->ResetDC(pDM);

}

}

Hope it helps you. Good luck.:-)