jaewoo082098
asked on
Urgent!! Printing problem
This is the source code for printing.
I got a problem here.
When I print out, the size of the printed is different in
laser printer and inkjet printer.
In laser printer, the size is smaller than that of inkjet printer.
Could you solve this problem?
I'm using Visual C++ 5.0.
Thank you in advance.
int clientX,clientY,temp;
CRect rectClient;
GetClientRect(rectClient);
clientX = rectClient.right;
clientY = rectClient.bottom;
temp = clientY - 50;
clientY = 1400;
// Load Blank Image
HANDLE hBitmap;
CBitmap *lpBitmap;
hBitmap = ::LoadImage(NULL,
"picture\\blankprint.bmp",
IMAGE_BITMAP,
clientX, clientY,
LR_LOADFROMFILE);
lpBitmap = CBitmap::FromHandle((HBITM AP)hBitmap );
// Make the Image for printing
CClientDC dc1(this);
CDC dc;
CDC dc2;
CPrintDialog dlg(FALSE);
CBitmap PrnBitmap;
CBrush p_brush;
dc.CreateCompatibleDC(&dc1 );
dc2.CreateCompatibleDC(&dc 1);
PrnBitmap.CreateCompatible Bitmap(&dc 1, clientX, clientY);
p_brush.CreateStockObject( WHITE_BRUS H);
dc.SelectObject(&p_brush);
dc.SelectObject(&PrnBitmap );
dc2.SelectObject(lpBitmap) ;
dc.BitBlt(0, 0, clientX, clientY, &dc2, 0, 0, SRCCOPY);
dc.BitBlt(0, 0, clientX, temp, &dc1, 0, 50, SRCCOPY);
dc.TextOut(20,clientY-120, "** Provider Information **",26);
dc.TextOut(20,clientY-100, "Doctor ID ", 10);
dc.TextOut(20,clientY-80, "Name ", 10);
dc.TextOut(20,clientY-60, "Address ", 10);
dc.TextOut(120,clientY-100 , doctorID,sizeof(doctorID)) ;
wsprintf(DName,"%s, %s\0",dLname, dFname);
int length = strlen(DName);
dc.TextOut(120,clientY-80, DName,length);
dc.TextOut(120,clientY-60, Addr1,sizeof(Addr1));
dc.TextOut(120,clientY-40, Addr2,sizeof(Addr2));
if(dlg.DoModal() == IDOK)
{
DOCINFO di;
memset (&di, 0, sizeof( DOCINFO) );
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = "Printing!";
dc.SetWindowExt(2100,1500) ;
dc.SetWindowOrg(0, 0);
HDC hdc;
hdc = dlg.GetPrinterDC();
::StartDoc(hdc,&di);
::StartPage(hdc);
::BitBlt(hdc, 100, 100, 2100, 3000, dc.m_hDC,
0, 0, SRCCOPY);
::RestoreDC(hdc,-1);
::EndPage(hdc);
::EndDoc(hdc);
}
delete dlg;
I got a problem here.
When I print out, the size of the printed is different in
laser printer and inkjet printer.
In laser printer, the size is smaller than that of inkjet printer.
Could you solve this problem?
I'm using Visual C++ 5.0.
Thank you in advance.
int clientX,clientY,temp;
CRect rectClient;
GetClientRect(rectClient);
clientX = rectClient.right;
clientY = rectClient.bottom;
temp = clientY - 50;
clientY = 1400;
// Load Blank Image
HANDLE hBitmap;
CBitmap *lpBitmap;
hBitmap = ::LoadImage(NULL,
"picture\\blankprint.bmp",
IMAGE_BITMAP,
clientX, clientY,
LR_LOADFROMFILE);
lpBitmap = CBitmap::FromHandle((HBITM
// Make the Image for printing
CClientDC dc1(this);
CDC dc;
CDC dc2;
CPrintDialog dlg(FALSE);
CBitmap PrnBitmap;
CBrush p_brush;
dc.CreateCompatibleDC(&dc1
dc2.CreateCompatibleDC(&dc
PrnBitmap.CreateCompatible
p_brush.CreateStockObject(
dc.SelectObject(&p_brush);
dc.SelectObject(&PrnBitmap
dc2.SelectObject(lpBitmap)
dc.BitBlt(0, 0, clientX, clientY, &dc2, 0, 0, SRCCOPY);
dc.BitBlt(0, 0, clientX, temp, &dc1, 0, 50, SRCCOPY);
dc.TextOut(20,clientY-120,
dc.TextOut(20,clientY-100,
dc.TextOut(20,clientY-80, "Name ", 10);
dc.TextOut(20,clientY-60, "Address ", 10);
dc.TextOut(120,clientY-100
wsprintf(DName,"%s, %s\0",dLname, dFname);
int length = strlen(DName);
dc.TextOut(120,clientY-80,
dc.TextOut(120,clientY-60,
dc.TextOut(120,clientY-40,
if(dlg.DoModal() == IDOK)
{
DOCINFO di;
memset (&di, 0, sizeof( DOCINFO) );
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = "Printing!";
dc.SetWindowExt(2100,1500)
dc.SetWindowOrg(0, 0);
HDC hdc;
hdc = dlg.GetPrinterDC();
::StartDoc(hdc,&di);
::StartPage(hdc);
::BitBlt(hdc, 100, 100, 2100, 3000, dc.m_hDC,
0, 0, SRCCOPY);
::RestoreDC(hdc,-1);
::EndPage(hdc);
::EndDoc(hdc);
}
delete dlg;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This means, say the ink jet printer's pixel lie within (0,0)-(2100,3000)
But for the laser printer, they lie within, say, (0,0)-(4000,5500).
(I'll elaborate more later, got no time now)