INFO: Using Printer Escapes w/PS Printers on Windows NT & Win32sID: Q124135
|
To identify and print to PostScript printers from a Win32-based application
under Windows NT and under Win32s, you need to special-case your code. This
is because the printer drivers respond to different Printer Escapes under
Windows NT and Windows/Win32s.
This article discusses how to identify and print to PostScript printers on
both Windows NT and Win32s.
int gPrCode = 0; // Set according to platform.
if( Win32s ) // Using the Win16 driver.
{
gPrCode = PASSTHROUGH;
if((Escape(printerIC, GETTECHNOLOGY, NULL, NULL, (LPSTR)szTech) &&
!lstrcmp(szTech, "PostScript")) &&
Escape(printerIC, QUERYESCSUPPORT, sizeof(int),
(LPSTR)gPrCode, NULL )
{
// The printer is PostScript.
...
}
}
else // Using Win32 driver under Windows NT.
{
gPrCode = POSTSCRIPT_PASSTHROUGH; // Fails with Win16 driver
if( Escape(printerIC, QUERYESCSUPPORT, sizeof(int), (LPSTR)gPrCode,
NULL))
{
// The printer is PostScript.
...
}
}
// Assuming a buffer, szPSBuf, of max size MAX_PSBUF containing
// nPSData bytes of PostScript data.
char szBuf[MAX_PSBUF+sizeof(short)];
// Store length in buffer.
*((short *)szBuf) = nPSData;
// Store data in buffer.
memcpy( (char *)szBuf + sizeof(short), szPSBuf, nPSData );
// Note that gPrCode (set when identifying the printer) depends on
// the platform.
Escape( printerDC, gPrCode, (int) nPSData, szBuf, NULL );
However, your output may appear scaled or translated incorrectly or data
may be transformed off the page under Win32s.
xres = GetDeviceCaps(printerDC, LOGPIXELSX);
yres = GetDeviceCaps(printerDC, LOGPIXELSY);
// Two leading spaces for the following operation.
wsprintf(szBuf, " %d 72 div %d 72 div scale\n", xres, yres);
// Put actual size into buffer
*((short *)szBuf) = strlen(szBuf)-2;
Escape( printerDC, gPrCode, strlen(szBuf)-2, szBuf, NULL );
Additional query words: 1.10 1.20 3.10
Keywords : kbDSupport kbSDKWin16
Version : winnt:3.1,3.5,3.51
Platform : winnt
Issue type : kbinfo
|
Last Reviewed: February 1, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |