printing with MFC
-
Pls dont send me any link i have gone through them , I have an MFC Application . My problem is simple that i have a document from which in need to print . but when i print the font size change gets small which is also visisble in the printpriview . is there any simple way by which i can have the same printout as it is visible in the frame window thanx Vikas Amin Embin Technology Bombay
-
Pls dont send me any link i have gone through them , I have an MFC Application . My problem is simple that i have a document from which in need to print . but when i print the font size change gets small which is also visisble in the printpriview . is there any simple way by which i can have the same printout as it is visible in the frame window thanx Vikas Amin Embin Technology Bombay
Show the code. Or try this, from MSDN :
// get the default printer
CPrintDialog dlg(FALSE);
dlg.GetDefaults();// is a default printer set up?
HDC hdcPrinter = dlg.GetPrinterDC();
if (hdcPrinter == NULL)
{
MessageBox(_T("Buy a printer!"));
}
else
{
// create a CDC and attach it to the default printer
CDC dcPrinter;
dcPrinter.Attach(hdcPrinter);// call StartDoc() to begin printing
DOCINFO docinfo;
memset(&docinfo, 0, sizeof(docinfo));
docinfo.cbSize = sizeof(docinfo);
docinfo.lpszDocName = _T("CDC::StartDoc() Code Fragment");// if it fails, complain and exit gracefully
if (dcPrinter.StartDoc(&docinfo) < 0)
{
MessageBox(_T("Printer wouldn't initalize"));
}
else
{
// start a page
if (dcPrinter.StartPage() < 0)
{
MessageBox(_T("Could not start page"));
dcPrinter.AbortDoc();
}
else
{
// actually do some printing
CGdiObject* pOldFont = dcPrinter.SelectStockObject(SYSTEM_FONT);dcPrinter.TextOut(50, 50, \_T("Code Project Rulezz"), 12); dcPrinter.EndPage(); dcPrinter.EndDoc(); dcPrinter.SelectObject(pOldFont); }
}
}
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
-- modified at 8:58 Monday 6th February, 2006 -
Pls dont send me any link i have gone through them , I have an MFC Application . My problem is simple that i have a document from which in need to print . but when i print the font size change gets small which is also visisble in the printpriview . is there any simple way by which i can have the same printout as it is visible in the frame window thanx Vikas Amin Embin Technology Bombay
In your view's
OnPrepareDC()
method, play around withSetMapMode()
,SetWindowOrg()
,SetViewportOrg()
,SetWindowExt()
, andSetViewportExt()
. I might have left a sample in the code for this article.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
-
Pls dont send me any link i have gone through them , I have an MFC Application . My problem is simple that i have a document from which in need to print . but when i print the font size change gets small which is also visisble in the printpriview . is there any simple way by which i can have the same printout as it is visible in the frame window thanx Vikas Amin Embin Technology Bombay
How are you creating your font for printing? You can use CreatPointFont(), passing in the printer DC which will account for the higher DPI of the printer as compared to the screen. Or you could use CreateFontIndirect() and calculating the LOGFONT.lfHeight variable depending on the DPI of the printer
logfont.lfHeight = -MulDiv(PointSize, PrinterDC.GetDeviceCaps(LOGPIXELSY), 72);
MyCFont.CreateFontIndirect(&logfont);I can't recall where I got the MulDiv formula from, but I am sure it is in MSDN somewhere.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04 "There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05 Within you lies the power for good - Use it!
-
Pls dont send me any link i have gone through them , I have an MFC Application . My problem is simple that i have a document from which in need to print . but when i print the font size change gets small which is also visisble in the printpriview . is there any simple way by which i can have the same printout as it is visible in the frame window thanx Vikas Amin Embin Technology Bombay
I'm having the same problem. ------- sig starts "I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001