Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the Printer Font

Status
Not open for further replies.

noaaprogrammer

Programmer
May 4, 2001
36
US
I have a problem. I have a dialog-based app that prints a document without using doc/view architecture. The problem is that it prints differently on some printers than it does on others. How can I ensure that it prints with the same font on all printers? Here is some code that is similar to the method that I used:

void CMyDialog::OnPrintBuf()
{
char pbuf[100] = "Hello World.";
HDC hdcPrn ;

// Instantiate a CPrintDialog.
CPrintDialog *printDlg =
new CPrintDialog(FALSE, PD_ALLPAGES | PD_RETURNDC, NULL);

// Initialize some of the fields in PRINTDLG structure.
printDlg->m_pd.nMinPage = printDlg->m_pd.nMaxPage = 1;
printDlg->m_pd.nFromPage = printDlg->m_pd.nToPage = 1;

// Display Windows print dialog box.
printDlg->DoModal();

// Obtain a handle to the device context.
hdcPrn = printDlg->GetPrinterDC();
if (hdcPrn != NULL)
{
CDC *pDC = new CDC;
pDC->Attach (hdcPrn); // attach a printer DC

pDC->StartDoc("test"); // begin a new print job
// for Win32 use
// CDC::StartDoc(LPDOCINFO) override

SetPrintAlign(pDC, hdcPrn);// Set the printing alignment

pDC->StartPage(); // begin a new page
pDC->TextOut(10, 10, pbuf);// write the string in pbuf
pDC->EndPage(); // end a page

pDC->EndDoc(); // end a print job

pDC->Detach(); // detach the printer DC
delete pDC;
}

delete printDlg;
}

void CMyDialog::SetPrintAlign(CDC *pDC, HDC hdcPrn)
{
short cxPage, cyPage;

cxPage = ::GetDeviceCaps(hdcPrn,HORZRES);
cyPage = ::GetDeviceCaps(hdcPrn,VERTRES);
pDC->SetMapMode(MM_ISOTROPIC);
pDC->SetWindowExt(1000,1000);
}

 
the print representation will be identical only in graphicall regime. John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top