Supporting PostScript Features in WindowsLast reviewed: August 5, 1996Article ID: Q74704 |
The information in this article applies to:
SUMMARYThere 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 INFORMATIONThe 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. }NOTE: In the event that GETTECHNOLOGY is not supported by some printer drivers, another method need to be used to determine if the printer is a PostScript printer. One possible method is to use QUERYESCSUPPORT on escapes that are only implemented by PostScript printers. For example:
EPSPRINTING SETLINEJOIN SETMITERLIMIT SET_POLY_MODESimilarly, you can determine a PCL printer by calling QUERYESCSUPPORT on the following escape:
DRAWPATTERNRECTThe second issue is how to print application-generated PostScript code. The mechanism from a Windows-based 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:
|
Additional reference words: 3.00 3.10
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |