H
hierro77
Hi,
I'm getting blank pages and the following when printing to PCL
printers:
PCL XL error
Subsystem: IMAGE
Error: CurrentCursorUndefined
Operator: BeginImage
Position: 14
The error does not occur when using PS drivers.
The printing is done using WTL's CPrintJob::StartPrintJob. In the
overriden CPrintJob:
rintPage being called the following is carried
out:
bool CMyPlugin:
rintPage(UINT nPage, HDC hDC)
{
int pageWidth = ::GetDeviceCaps(hDC, PHYSICALWIDTH) - 2 *
::GetDeviceCaps(hDC, PHYSICALOFFSETX);
int pageHeight = ::GetDeviceCaps(hDC, PHYSICALHEIGHT) - 2 *
::GetDeviceCaps(hDC, PHYSICALOFFSETY);
// calc scaling factor, so that bitmap is not too small
// (based on the width only, max 3/4 width)
unsigned w = 682, h = 548;
mWbPort->SetWindowSize(w, h);
int nScale = ::MulDiv(pageWidth, 10, 11) / w;
if(nScale == 0) nScale = 1; // <- safety
// calc margins to center bitmap
int xOff = (pageWidth - nScale * w) / 2;
if(xOff < 0) xOff = 0;
int yOff = (pageHeight - nScale * h) / 2;
if(yOff < 0) yOff = 0;
// ensure that preview doesn't go outside of the page
int cxBlt = nScale * w;
if(xOff + cxBlt > pageWidth) cxBlt = pageWidth - xOff;
int cyBlt = nScale * h;
if(yOff + cyBlt > pageHeight) cyBlt = pageHeight - yOff;
CDC dc = CreateCompatibleDC(mDcMem);
CBitmap bmp = CreateCompatibleBitmap(mDcMem, w, h);
dc.SelectBitmap(bmp);
COLORREF oldCol = mWbPort->OutPageColor();
mWbPort->SetOutPageColor(RGB(255, 255, 255));
mWbPort->Paint(dc);
mWbPort->SetOutPageColor(oldCol);
// now paint bitmap
int oldStretchMode = ::SetStretchBltMode(hDC, HALFTONE);
::StretchBlt(hDC, xOff, yOff, cxBlt, cyBlt, dc, 0, 0, w, h, SRCCOPY);
::SetStretchBltMode(hDC, oldStretchMode);
dc.SelectBitmap(0);
dc.DeleteDC();
bmp.DeleteObject();
mWbPort->SetWindowSize(mWndSizeX, mWndSizeY);
return true;
}
Any idea what's causing the error and blank pages?
I'm getting blank pages and the following when printing to PCL
printers:
PCL XL error
Subsystem: IMAGE
Error: CurrentCursorUndefined
Operator: BeginImage
Position: 14
The error does not occur when using PS drivers.
The printing is done using WTL's CPrintJob::StartPrintJob. In the
overriden CPrintJob:

out:
bool CMyPlugin:

{
int pageWidth = ::GetDeviceCaps(hDC, PHYSICALWIDTH) - 2 *
::GetDeviceCaps(hDC, PHYSICALOFFSETX);
int pageHeight = ::GetDeviceCaps(hDC, PHYSICALHEIGHT) - 2 *
::GetDeviceCaps(hDC, PHYSICALOFFSETY);
// calc scaling factor, so that bitmap is not too small
// (based on the width only, max 3/4 width)
unsigned w = 682, h = 548;
mWbPort->SetWindowSize(w, h);
int nScale = ::MulDiv(pageWidth, 10, 11) / w;
if(nScale == 0) nScale = 1; // <- safety
// calc margins to center bitmap
int xOff = (pageWidth - nScale * w) / 2;
if(xOff < 0) xOff = 0;
int yOff = (pageHeight - nScale * h) / 2;
if(yOff < 0) yOff = 0;
// ensure that preview doesn't go outside of the page
int cxBlt = nScale * w;
if(xOff + cxBlt > pageWidth) cxBlt = pageWidth - xOff;
int cyBlt = nScale * h;
if(yOff + cyBlt > pageHeight) cyBlt = pageHeight - yOff;
CDC dc = CreateCompatibleDC(mDcMem);
CBitmap bmp = CreateCompatibleBitmap(mDcMem, w, h);
dc.SelectBitmap(bmp);
COLORREF oldCol = mWbPort->OutPageColor();
mWbPort->SetOutPageColor(RGB(255, 255, 255));
mWbPort->Paint(dc);
mWbPort->SetOutPageColor(oldCol);
// now paint bitmap
int oldStretchMode = ::SetStretchBltMode(hDC, HALFTONE);
::StretchBlt(hDC, xOff, yOff, cxBlt, cyBlt, dc, 0, 0, w, h, SRCCOPY);
::SetStretchBltMode(hDC, oldStretchMode);
dc.SelectBitmap(0);
dc.DeleteDC();
bmp.DeleteObject();
mWbPort->SetWindowSize(mWndSizeX, mWndSizeY);
return true;
}
Any idea what's causing the error and blank pages?