void CESPacsDlg::Print_Text_Report()
{
CDC dc;
CPrintDialog printDlg(FALSE);
if (printDlg.DoModal() != IDOK)             // Get printer settings from user
return;
dc.Attach(printDlg.GetPrinterDC());         // attach a printer DC
dc.m_bPrinting = TRUE;

CString strTitle;
strTitle.LoadString(AFX_IDS_APP_TITLE);
DOCINFO di;                                 // Initialise print doc details
memset(&di, 0, sizeof (DOCINFO));
di.cbSize = sizeof (DOCINFO);
di.lpszDocName = strTitle;
BOOL bPrintingOK = dc.StartDoc(&di);        // Begin a new print job CPrintInfo Info;
Info.m_rectDraw.SetRect(0,0, dc.GetDeviceCaps(HORZRES), dc.GetDeviceCaps(VERTRES)); OnBeginPrinting(&dc, &Info);                // Initialise printing
for (UINT page = Info.GetMinPage(); page <= Info.GetMaxPage() && bPrintingOK; page++)
{
dc.StartPage();                         // begin new page
Info.m_nCurPage = page;
OnPrint(&dc, &Info);                    // Print page
bPrintingOK = (dc.EndPage() > 0);       // end page
}
OnEndPrinting(&dc, &Info);                  // Clean up after printing if (bPrintingOK)
dc.EndDoc();                            // end a print job
else
dc.AbortDoc();                          // abort job.
// dc.Detach();                              // detach the printer DC
dc.DeleteDC ();
}void CESPacsDlg::OnBeginPrinting(CDC *pDC, CPrintInfo *pInfo)
{
    pInfo->SetMaxPage(1);
    pInfo->m_nCurPage = 1;                        // start printing at page# 1
}void CESPacsDlg::OnPrint(CDC *pDC, CPrintInfo *pInfo)
{
}
void CESPacsDlg::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{}