# Special File Handling

*VIEWER* | Print Preview

## Formats

1. | Open for Preview: | OPEN (chan)"*VIEWER* [ ;options ]"
2. | Via WindX: | CALL "*WindX.utl;SPAWN","*VIEWER* -XT=1 -ARG filename[DELETE]"
3. | Via Command Line: | path\PVX\PXPLUS.EXE"*VIEWER* -XT=1 -ARG filename[DELETE]"

Where:

chan | Channel or logical file number (e.g. open (1)"*viewer*").
DELETE | Optional keyword. Use the DELETE to tell PxPlus to erase the file when the viewer closes.
filename$ | Name of the file that the print job is stored in or being spooled to. The file must be a serial file and not locked. See SERIAL directive. To override the normal requirement that a serial file be locked, use 'LU' system parameter.
PVX | PXPLUS.EXE | Command to launch PxPlus. See Launching PxPlus.
*VIEWER* | Keyword, not case-sensitive. Special interface, enclosed in quotation marks within OPEN directive. (Include * asterisks in syntax)
options | A series of semi-colon separated options that can be used to set the Margins, Orientation, Paper size, etc. of the printer that the viewer is to emulate. Specific properties are listed under WINPRT_SETUP Properties.
*WINDX.UTL;SPAWN | PxPlus utility;function. See Format 10: [WDX] and *WindX.utl.

## Description

#### Note:
*VIEWER* is supported for use in WindX or Windows only.

The *VIEWER* is a special device file for previewing reports. The *VIEWER* is able to:

- Capture a print job to a file.
- View currently spooling print jobs or print jobs stored on the disk.
- Work on the local Windows client via WindX.
- Zoom in/out in four states.
- GoTo: Page, First Page, Last Page, Previous Page, Next Page, Specific Page Number.
- Search text.
- Copy to the Clipboard.
- View a job while it is still spooling.

#### Note:
If the global variable %PDF_DEFAULT$ contains the option VIEWER, the system built-in PDF driver and external PDF viewer will be used whenever the application opens *VIEWER*.

An OPEN may specify a number of semi-colon separated options for invoking the VIEWER interface. These may be included as part of the path or within the OPT= clause:

> OPEN(chan,OPT="option;option;…")"*VIEWER*"

Two special options (INLINE and ONCLOSE) can be used to control how the preview is created at run time. These and other options are described below.

*VIEWER* Output Parameters

The options that can be used to define PDF output are:

Option | Description
COLLATE=YES | NO | (Printer Output Only) Collate paper.
COLOR=YES | NO or COLOUR=YES | NO | (Printer Output Only) Colored print.
COLUMNS=num | (Text-based Reports Only) Minimum number of columns.
COPIES=num | (Printer Output Only) Set number of copies.
CREATED | Used to document the output file when it is saved.
DPI | Resolution in dots per inch.
FONT=fontspec | Default font for reports. Defaults to "Courier New, -10".
FONTSIZE=num | Default font size for reports.
INLINE | See *PDF* Output Parameters.
MARGINS=top :left:right:bottom or MARGIN=top:left:right:bottom | Defines margin settings in 1/1000ths of an inch.
ONCLOSE | Invokes a new instance of the viewer interface when the printer channel is closed.
ORIENTATION=LANDSCAPE | PORTRAIT | Swap output width for length, and vice versa.
PAGINATIONAT=num | Auto form feed at row.
PAPERSIZE=num | Define paper size.
PRINTER=string | Associated printer name.
QUALITY=num | (Printer Output Only) Specifies DPI, 0 (or unspecified) = printer default.
RANGE=num | from:to | Select only specific page number or range to print.
ROWS=num | (Text-based Reports Only) Minimum number of rows.
SCALETOFIT | (Text-based Reports Only) Resize report to fit paper size.
SOURCE=num | Set specific paper source.
SUPPRESSALLBLANKPAGES | Suppress all blank pages.
SUPPRESSFIRSTBLANKPAGE | Suppress first blank page.
SUPPRESSWATERMARKS | Suppress watermark display.
TITLE=string | Add Title tag to preview. Can also be used to complete the information in the Windows Print Job window.
USER | Used to document the output file when it is saved.
WATERMARKIMAGE=string | Image name, assumes 100 pixels to the inch.
WATERMARKIMAGELOCATION=num | 0 = Centered 1 = Tiled 2 = Top Left 3 = Top Right 4 = Bottom Left 5 = Bottom Right
WATERMARKTEXT=string | Watermark text.
WATERMARKTEXTFONT=fontspec | Font for watermark text.
WATERMARKTEXTLOCATION=num | 0 = Centered 1 = Tiled 2 = Top Left 3 = Top Right 4 = Bottom Left 5 = Bottom Right
WATERMARKTEXTROTATION=num | Text rotation, angle in degrees.

The following six options are used only if the 'CP', 'EP' and 'SP' mnemonics are encountered in the report. If not set, then the viewer will attempt to set correct values for each. It is not necessary to set all of these items. Simply setting SPCols is enough. The values for 'CP' and 'EP' are calculated, and the Rows= will all default to the same value.

Option | Description
CPCOLS=num | 0 to 255, number of columns when in 'CP'.
CPROWS=num | 0 to 255, number of rows when in 'CP'.
EPCOLS=num | 0 to 255, number of columns when in 'EP'.
EPROWS=num | 0 to 255, number of rows when in 'EP'.
SPCOLS=num | 0 to 255, number of columns when in 'SP'.
SPROWS=num | 0 to 255, number of rows when in 'SP'.

## Example

The following example illustrates how to open and use the *VIEWER* for print preview:

> CHAN=unt;
> open (CHAN)"*VIEWER*"
> print (CHAN)'font'("Courier New",-10),'DF',
> print (CHAN)'font'("Arial",2),'text'(@x(2),@y(2),"Fonted Text"),
> print (CHAN)'picture'(@x(3),@y(5),@x(43),@y(30),"*win/nomads2"),

#### Note:
Set the 'BM' mnemonic to On to have the *VIEWER* send all data directly to the print file without interpretation. This allows you to send print jobs to any Windows printer that is available on the client PC. The *VIEWER* filters out the first and/or last page if either is blank.

The *VIEWER* does not return values for maximum column/line; i.e. in MXC( ) / MXL( ) functions.

The following example illustrates how to approximate the number of columns:

> CHAN=unt;
> open (CHAN)"*WINPRT* POINTSZ=-10"
> LOOP:
> print (CHAN)'font'("Courier New",POINTSZ),'DF',
> if mxc(CHAN)<132 \
> then POINTSZ+=2;
> goto LOOP
> LINES=mxl(CHAN),COLS=mxc(CHAN)
> print (CHAN)'AB', ! <--- aborts print job
> close (CHAN)
> open (CHAN)"*VIEWER*"
> print 'font'("Courier New",POINTSZ),'DF',mn/line