ID Number: Q74704
3.00 3.10
WINDOWS
Summary:
There are some issues involved when designing an application to
provide support for PostScript printers. The application must
determine if the PostScript driver is available by using an accurate
detection system. If an application generates PostScript directly, the
PASSTHROUGH escape can be used to send the file. This must be done
with care because the application is communicating directly with the
printer.
More Information:
The first issue is how to determine if a PostScript driver is an
installed printer driver under Windows. An application cannot assume
the PostScript driver is named PSCRIPT.DRV because this forces
PostScript driver vendors to use the same filename. The correct method
is to run code similar to the pseudocode below:
bFound = FALSE;
for (each device in [Devices] section of win.ini) {
/* extract the necessary fields from the ini line */
szDriverName = driver name extracted from ini line
szModelName = left side of ini line (the key)
szPort = port name extracted from ini line.
hIC = CreateIC(szDriverName, szModelName, szPort, NULL);
if (hIC) {
/* see if driver supports GETTECHNOLOGY escape */
wEscape = GETTECHNOLOGY;
if (Escape(hIC, QUERYESCSUPPORT, sizeof(WORD), &wEscape, NULL)) {
Escape(hIC, GETTECHNOLOGY, 0, NULL, &szTechnology);
/* Check that the string starts with PostScript
* by doing a case-insensitive search. Allow
* for the possibility that the string could be
* longer, like "PostScript level 2" or some other
* extension.
*/
if (beginning of string is "PostScript")
bFound = TRUE;
}
DeleteDC(hIC);
}
/* if the driver has been found break out */
if (bFound)
break;
}
if (bFound) {
PostScript driver is szDriverName, model is szModelName, port is
szPort.
}
The second issue is how to print application-generated PostScript
code. The mechanism from a Windows application is through the
PASSTHROUGH escape. The PASSTHROUGH escape is documented in the
"Microsoft Windows Software Development Kit Reference Volume 2,"
Chapter 12. In addition to the documentation, one requirement on the
buffer passed is easy to miss; the first word must contain the length
of the buffer. The contents of the data sent by PASSTHROUGH can alter
the state of the printer.
To be safe, obey the following rules:
1. Surround PASSTHROUGH data by save/restore PostScript operators.
2. Do not embed GDI calls between PASSTHROUGH escapes. For example:
PASSTHROUGH(save)
Rectangle
OtherGDIRoutines
PASSTHROUGH(restore)
Some driver code and software fonts are downloaded to the printer
under certain conditions. The above operations could cause the
driver and printer to loose synchronization, and potentially cause
the job to fail. In general, no assumptions should be made
concerning the code generated by a given GDI call.
3. Do not send a command to cause a page ejection.
Additional reference words: 3.00 3.10 3.x