Using Printer Drivers in Coded Output

ID: Q88579

2.00 2.5x 2.6x MS-DOS kbprint kbprg

The information in this article applies to:

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

Keywords          : FxprintDriver 
Version           : 2.00 2.5x 2.6x
Platform          : MS-DOS

Last Reviewed: December 19, 1995