Microsoft KB Archive/74704

{|
 * width="100%"|

INFO: Supporting PostScript Features in Windows

 * }

Q74704

3.00 3.10 WINDOWS kbprg

-

The information in this article applies to:


 * Microsoft Windows Software Development Kit (SDK) 3.1

-

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 following pseudocode:

  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 &quot;PostScript level 2&quot; or some other * extension. */                         if (beginning of string is &quot;PostScript&quot;) 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_MODE Similarly, you can determine a PCL printer by calling QUERYESCSUPPORT on the following escape:

  DRAWPATTERNRECT The 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 &quot;Microsoft Windows Software Development Kit Reference Volume 2,&quot; 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:

 Surround PASSTHROUGH data by save/restore PostScript operators.  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 lose synchronization, and potentially cause the job to fail. In general, no assumptions should be made concerning the code generated by a given GDI call.  Do not send a command to cause a page ejection.

Additional query words: 3.00 3.10

Keywords : _IK kbSDKWin16

Issue type : kbinfo

Technology : kbAudDeveloper kbWin3xSearch kbSDKSearch kbWinSDKSearch kbWinSDK310