In BeginPrinting, I calculate the printing rect like below. I rely on this to count the number of pages.
CRect rect(30, -50, 200, -60);
int height = pDC->DrawText(cstr, &rect, DT_EDITCONTROL | DT_WORDBREAK | DT_LEFT | DT_CALCRECT);
Then in OnPrint, I do the same calculation again. However, the height result is different. I don't know what could be wrong with it.