Supporting PostScript Features in Windows

Last reviewed: August 5, 1996
Article ID: Q74704
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) for Windows versions 3.1 and 3.0

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.
   }

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 "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 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.

  3. Do not send a command to cause a page ejection.


Additional reference words: 3.00 3.10
KBCategory: kbprg
KBSubcategory: GdiPrn


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 5, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.