Using Printer Drivers in Coded Output

Last reviewed: December 18, 1995
Article ID: Q88579
The information in this article applies to:
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5x, 2.6x

SUMMARY

To use a printer driver in a FoxPro application, additional code is required. The text below provides examples of the necessary code.

MORE INFORMATION

NOTE: The following code may need to be modified to work with your specific printer.

PostScript Driver

The PostScript printer driver is unique because it is the only driver that parses the data it receives and adjusts the output for any special characters it receives. For example, when a left parenthesis ("(") is printed with the PostScript driver, the driver adds a backslash character (\) to the data stream. For this reason, a printer driver must not be affected when the PDDOCST and PDDOCEND procedures make these changes. The value returned from these procedures is sent to the PDOBJECT procedure and evaluated.

The following code fragment demonstrates how to use a PostScript printer driver in an application:

   SET TALK OFF
   *
   * Set PDSETUP to any valid PostScript printer driver listed in the
   * FOXUSER database.
   SET PDSETUP TO "PALATINO 10"
   SET LIBRARY TO GOODIES\PDRIVERS\PSAPI.PLB
   *
   * To print to a network printer, change the following command.
   SET PRINTER TO TEST.TXT
   SET PRINT ON
   *
   * Save the printer driver setup and remove the printer driver.
   * Doing so prevents the PostScript printer driver from interpreting
   * the information in the page header. Afterwards, set the printer
   * driver back to its initial setting.
   *
   X=SET("PDSETUP")
   SET PDSETUP TO
   ?PDDOCST(_PLENGTH,128)
   SET PDSETUP TO (X)

   ? "This is a test"

   *
   * Return the printer driver to its initial setting.
   *
   X=SET("PDSETUP")
   SET PDSETUP TO
   ?PDDOCEND()

   SET PRINT OFF
   SET PRINTER TO
   SET LIBRARY TO

Non-PostScript Printer

The following code fragment demonstrates how to use the Hewlett-Packard Printer Control Language (HP-PCL) printer driver in an application:

   SET TALK OFF
   SET PDSETUP TO "HP"
   SET LIBRARY TO GOODIES\PDRIVERS\DRIVER2.PLB
   *
   * To print to a network printer, change the following command.
   SET PRINTER TO TEST.TXT
   SET PRINT ON
   PRINTJOB

   ? PDDOCST(_PLENGTH,128)
   ? "This is a test"
   ? PDDOCEND()

   ENDPRINTJOB
   SET PRINT OFF
   SET PRINTER TO
   SET LIBRARY TO
   SET PDSETUP TO "HP"

.PRG in GENPD.APP

NOTE: The following code may need to be modified to work with your specific printer.

When you are using _pdriver="driver.prg" in GENPD.APP, use the following code:

   SET TALK OFF
   SET PDSETUP TO "HP"
   SET PROCEDURE TO GOODIES\PDRIVERS\DRIVER.PRG

NOTE: Instead of using SET LIBRARY TO, you use SET PROCEDURE TO.


Additional reference words: FoxDos 2.00 2.50 2.50a 2.50b 2.60 2.60a report
KBCategory: kbprint kbprg
KBSubcategory: FxprintDriver


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: December 18, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.