# Introduction to Using PxPlus

Printing |

PRINT (?) is the directive for formatting and displaying data at the console (screen, display). However, as the keyword suggests, PRINT can also be used to render text and images on paper using a hard copy device (printer). Actually, the definition of "printing" is not limited to hard copy format. In PxPlus, this can mean any process by which the data (reports, documents or images) are sent to an output destination (device, interface or file format).

Unless the output is intended for immediate display, a PRINT statement must include a valid channel number to indicate a destination other than the PxPlus console. Channels are established using an OPEN directive, which identifies the connection to a specific device, interface or file. See Opening/Closing Devices and Files.

Printing requires the use of both the OPEN directive and the PRINT directive:

| OPEN | To assign a channel number to an output destination
| PRINT | To format and direct output data to the destination defined via OPEN

## Printing Options

The PxPlus environment is designed for graphical application development, platform and device independence and for the migration of older code to newer technologies. As a result, it comes equipped with a variety of PRINT destinations (see PRINT Destinations below) to accommodate a broad range of application printing requirements.

PxPlus allows you to control all the steps in the printing process, but the end result is contingent on which method is used and on how the different parts work together. So how do you determine which tools are right for the job?

It is important to understand the capabilities, the limitations and the intended purpose of the different printing methods before you try to incorporate them into your PxPlus application:

- If your PxPlus application is designed run in Microsoft Windows, then you should be able to handle most hard copy printing tasks using the standard Windows printer interface *WINPRT*. Output may be controlled using various Graphical Mnemonics and through defaults established by the WINPRT_SETUP directive. See Printing in MS Windows.
- Legacy or converted character-based programs can use *WINPRT* just as easily, provided they are running under Windows. However, output that requires direct-to-device access (via raw escape sequences) should be sent to the *WINDEV* interface instead. See Character-Based Printing.
- UNIX/Linux-based PxPlus programs can access either *WINPRT* or *WINDEV* via WindX. If you are printing over a network print spooler or using a local port connection, the specific UNIX/Linux print routines may be maintained using custom print drivers and link files (explained in the next point).
- When your application has specific output requirements that need to be customized for different environments and/or multiple devices, then you should make use of a custom print driver. This is a basic PxPlus file that allows you to maintain initialization code, mnemonics, and device-specific control sequences outside your application. Devices, device drivers and other settings can be easily maintained (and are interchangeable) when defined using a link. See Print Drivers and Link Files.
- PRINT destinations are not limited to hard copy. PxPlus has an extensive list of output choices, which include the generation of HTML, 24-bit colour bitmap images, PDF-compatible files, and the Print Preview facility. See Logical Printers.
- Under WindX, *WINPRT* and *WINDEV* interfaces are accessible on the Windows system that issues the command. The [WDX] prefix is required to ensure that print jobs and dialogues are directed to the client. See Printing via Thin-Clients.

## Character-Based vs. Graphical Printing

In the section Programming Constructs, the PRINT directive is first introduced within the context of a character-based implementation of PxPlus. This is also referred to as character mode, and it defines syntax elements for generating line-oriented output on both the printer and screen.

By default, character-based PRINT statements will only advance by one line at a time when they print to the page. Automatic advance can be overridden by placing a hanging comma after the statement. *WINPRT* has been designed to minimize changes to existing text-based applications and allow virtually any printer to be used. See Character-Based Printing.

Graphical mode in PxPlus takes the original character mode behavior and has added syntax elements that are capable of graphical, page-oriented output. This implementation is ideally suited for GUI (graphical user interface) applications and is designed for sending graphical data to a Windows printer.

#### Note:
Character and graphical mode methods may be mixed to produce desired output; however, be careful to ensure that the mixed elements are compatible.
For example, using 'FONT' and 'DEFAULT' or 'DF' mnemonics to change character mode fonts can affect the x/y positioning of graphical output.

## PRINT Destinations

Physical printers, printer interfaces and output files can all be classified as PRINT destinations in PxPlus if they are made available for use (in an OPEN statement). There are several options for defining how, where and in which format the output will be sent.

For syntax options for the logical file names (i.e. *WINPRT*, *PDF*), see Special File Handling.

*BITMAP* | (WindX or Windows Only) Generates 24-bit colour bitmap images in memory. Example: OPEN (12)"*bitmap*"; PRINT 'CS' *BITMAP* contents can be accessed via the 'PICTURE' mnemonic and the SAVE FILE directive. See Logical Printers.
*HTML* | Generates HTML-formatted reports. Example: OPEN (1,OPT="FILE=Sample.htm;SHOW;FONT=Courier New;TITLE=Sample;BACK=FFFFFF;TEXT=000000")"*HTML*" Reports that are formatted using normal fixed fonts may be read using any HTML viewer (browser). The system prompts for a file name to store the resulting HTML document. See Logical Printers.
*PDF* | Generates a PDF file from PxPlus output. Example: OPEN (1) "*pdf*;FILE=/tmp/pvx.pdf; FORM=Letter:8.5in:11in" If the file name is omitted, a dialogue appears for users to specify the path, PDF name, and properties. See Logical Printers.
*VIEWER* | (WindX or Windows Only) Allows users to preview reports. Example: OPEN (CHAN)"*VIEWER*" This renders output to a screen "viewer" exactly as it would print out in hard copy format via *WINPRT*. See Logical Printers.
*WINDEV* | (WindX or Windows Only) Sends character-based data to the Windows print sub-system/spooler. Example: OPEN (1)"*WINDEV*;HP Laser Jet on \\Main_Server\HPLaser" This permits the Windows equivalent of sending data to a directly connected printer. It provides an interface to the Windows API in a pass-through mode that accepts raw data and device-specific escape sequences. See Raw Printing. For graphical printing, use *WINPRT* (see below).
*WINPRT* | (WindX or Windows Only) Enables standard API access to the Windows print sub-system/spooler. Example: OPEN (1)"*WINPRT*" This provides access to the standard Windows Printer dialogue for both graphical and character-based data; however, raw escape sequences are not permitted in graphical printing. For raw printing, see *WINDEV* (see above). Use the WINPRT_SETUP directive to establish default printing options for the Windows printer; i.e. paper size, margins, copies, etc. See Printing in MS Windows.
LPT Access | Specifies the port number of a directly connected printer device. Example: OPEN (1)"*LPT1*" This format accepts raw data, along with printer escape sequences, but does not support graphical printing. See Raw Printing.
UNC Name | (WindX or Windows Only) Specifies the location of a shared server/printer on the network. Example: OPEN (1)"\\Print_Server\HP_Laser" The output device can be any shared resource that is identified via Universal Naming Convention. This format accepts raw data, along with printer escape sequences, but does not support graphical printing.

## See Also

Converting to Graphical Reporting