WPRINT Utility Program Overview

In its most basic form, the WPRINT utility allows you to print WordPerfect version 8 through 4.2 documents without using the WordPerfect 8 program. This is based on a similar utility in the Unix WordPerfect 6.0 package. Both its WordPerfect 6.0 and 5.1 predecessor and WPRINT use command line parameters to create and send a print job.

The WPRINT utility, in the WordPerfect 8 package, goes beyond this basic functionality. Not only does WPRINT have the capability to print WordPerfect documents, but it can reformat those documents, if necessary, before printing. Some of the other new capabilities are:

Do a mail merge before printing the results of the merge

Convert some non-WordPerfect 8 documents to the WordPerfect 8 format and then print them.

In the past some developers have used WPRINT's predecessor as the engine for a WordPerfect 6.0 document print server or to automate the process of printing documents for a given situation. This same functionality (for WordPerfect 8 documents), can be used for developers that want to do similar automation projects in conjunction with WordPerfect 8.

As mentioned above, the WPRINT utility comes with the WordPerfect 8 package. The command line parameters used are documented in the manual that comes with WordPerfect 8.

Most of the command line parameters can be easily found by a user, or they will automatically default to the user's default printer information if left blank. But from the point of view of an application of some kind, the information may not be directly available, and the user's default printer information may not be the desired information.

In these cases an application may need to look in other files to get some of the information it needs to send a print job, or perform a merge/print combination. The following documentation has been provided for developers that may need to gather further information for their WPRINT based projects.

WPDEST.DEF FORMAT FOR WordPerfect 8

Overview

The WPDEST.DEF file contains basic printer port information. Some of this information may be needed for use with the WPRINT utility program. The WPDEST.DEF file is composed of 4 parts, a standard 16 byte Corel Corp. identification header, a "number of destinations" field, one or more destination definitions, and a string pool. The following information covers the format of each of these parts.

This documentation uses the following format:

Size Symbol	Meaning 1	Meaning 2

< >	Byte	Character

[ ]	Word	Short Integer

{ }	Double Word	Long Integer

All fields are unsigned unless they show a negative value, or state otherwise.

Values greater than 9 will be documented in decimal and then in hex. The hex value will follow the decimal value and will begin and end with parenthesis.

Fields that are arrays of byte, short integer, or long integer will be followed by a space, lower case "x", another space, and the number of elements in the array. For example "<Field> x 10" means that "Field" is a byte array of 10 elements. If the length of the array is variable the number of elements will be a "?" character. For example, "[Field2] x ?" means a variable length, short integer array called "Field2".

If you have worked with the WordPerfect 6.0 or 5.1 WPPORT file in the past, you will find this format to be VERY similar.

All fields that have a size greater than a byte are stored in "Intel order". In this order, the low byte comes first and the high byte comes second.

WPFile 16 byte Header

<WP File ID (always -1 (0xFF),"WPC")> x 4

{Start of Document (always 16 (0x10)}

<Product Type (always 18 (0x12)>

<File Type (always 14 (0x0E)>

<Major Version # (always zero)>

<Minor Version # (always zero)>

[Encryption Key (always zero)]

[Reserved (always zero)]

At offset 16 (starting at 0), Number of Destinations Field

[Number of destinations]

At offset 18, Destination Definitions

The following 71 bytes of destination definition is repeated for each available printer.

<Destination Id (A unique number identifier for q-picture file)> x 4

<Date of destination creation (not used)> x 4

<Destination type>

Destination Type	Byte Value

Dedicated Device	2

lpr Spooler	3

lp Spooler	4

Remote lpr Spooler	5 (not used in 6.0)

Remote lp Spooler	6 (not used in 6.0)

Other Spooler	7

Passthru	8

AIX Spooler	9

Remote AIX Spooler	10 (not used in 6.0)

<Number of data bits for destination (7 or 8)>

<Parity required by the printer>

Parity	Byte Value

Even	'E'

Odd	'O'

None	'N'

<Standard terminal i/o defines for baud rate>

Baud Rate	Byte Value

BAUD_PARALLEL	0

BAUD_50	1

BAUD_75	2

BAUD_110	3

BAUD_134	4

BAUD_150	5

BAUD_200	6

BAUD_300	7

BAUD_600	8

BAUD_1200	9

BAUD_1800	10

BAUD_2400	11

BAUD_4800	12

BAUD_9600	13

BAUD_19200	14

BAUD_38400	15

<Filter option for the lpr spooler>

Filter Option	Byte Value

Cifplot filter	'c'

Ditroff filter	'n'

Fortran filter	'f'

Graph Data filter	'g'

Raster Image filter	'v'

Tex filter	'd'

Troff filter	't'

<Type of handshaking used by printer>

Handshaking	Byte Value

HS_XON_XOFF	1

HS_HARDWARE	2

<Delay Value>

Used before restoring the original line settings on a serial device.

NOTE:	The following are pointer offsets into the destination def string pool

{ptr to Unique Destination Description}

{ptr to the user or groups who own this Destination}

{ptr to the name of host where this destination was defined}

{ptr to the name of host where print jobs are to be submitted}

{ptr to the system destination name 1}

{ptr to the system destination name 2}

{ptr to the device name (relevant to Dedicated WPCorp Device only)}

{ptr to the string to start spooler}

{ptr to spooling flags}

{ptr to Stty line settings string}

{ptr to job types defined for this destination}

{ptr to switch box string for electronic switch boxes}

{ptr to path and filename of header}

{ptr to path and filename of trailer}

Destination Def String Pool Information

The string pool contains a list of strings pointed to by each destination definition.

The string pool immediately follows the last printer destination definition. To find the string pool's offset, take the number of printers (the value at offset 16) * 71 (the number of bytes for a destination definition) + 18 (the start of the printer destination definitions area) = destination def string pool

Each destination definition contains a table of 14 offsets (see above)into the string pool. Each offset is an offset from the beginning of the string pool, not from the beginning of the file.

The maximum length of the "Unique Destination Description" is 41 bytes, including string terminator. The "Device Name", "String to start Spooler", and most other strings can be a maximum of 160 bytes (including terminator) unless otherwise stated below.

The "ptr to the user or groups who own this Destination" field points to the users or groups who have access rights. This information is not a string, but a table of information. The first entry (the one pointed to by the "ptr to the user or groups" field) in the table is a word (unsigned short integer) value of the number of user/group entries that follow. Each of the following entries in the table have the following format:

<Type>

1=Group

2=User

{Group or User ID}

<Group or User Name> x 10

If the "Group or User Name" field is less than 10 bytes long, it is null terminated and the remaining bytes are padded with garbage. Since the standard length for these names is a maximum of 8 bytes, the ninth byte would be the terminator and the tenth byte garbage in a full length name.

The "ptr to the name of host where print jobs are to be submitted" field refers to the host where print jobs are submitted to the spooler.

The "ptr to the system destination name 1" field refers to the system destination name where the WPCorp destination was defined.

The "ptr to the system destination name 2" field refers to the system destination name where print jobs are to be spooled.

The "spooling flags" are used only when wpdest knows the WordPerfect print formatter (wpp) cannot be invoked by the system spooler. These flags are ignored when a Custom Spool Command is used.

The "Stty line settings" string is used to initialize the system destination device communications.

The "ptr to job types defined for this destination" pointer actually points to a table of values. The first entry in the table (the one pointed to by "ptr to job types") is a word (unsigned short integer) value that indicates the number of entries, that follow, in the table. After this value each entry in the table is a maximum of 22 bytes long and has the following format:

<Marker>

'*'=	Job type is available in WP

'+'=	default (only 1 can have this mark)

' '=	Job type is not available in WP

<Job Type Name> x 20

<Null Terminator>

If the "Job Type Name" is less than 20 bytes long, it is null terminated and the remaining bytes are padded with garbage. If the "Job Type Name" string is 20 bytes long, the "Null Terminator" field at the end of the table entry is used to terminate the string.

.SET File Printer Packet Information

Overview

This information is not as important to WPRINT 8 as it was to its WordPerfect 5.1 predecessor. If the command line parameters that require printer information, are left blank, the WPRINT utility will use the user's default printer. The "default printer" is the printer the user has currently defined in WordPerfect 8.0. So supplying .SET file information is not as critical as it once was.

But if your program requires the list of printers that are available to a given user, or you have some other special reason, this information is documented below.

In some of the information below references are made to "word strings". WordPerfect word strings are character strings where each character of the string is composed of 2 bytes rather than one. Like any other sting, a word string is terminated with zero. But word strings terminate with 2 bytes of zero instead of the standard 1 byte.

Each word string character's high byte contains the WordPerfect character set the character belongs to, and the low byte is the character in that character set. The complete character is read as an unsigned short integer. ASCII characters have been mapped into WordPerfect character set zero. To put an ASCII character into a word string, the high byte would be zero and the low byte would be the ASCII value for that character. Refer to the WordPerfect 8.0 reference manual for a complete list of WordPerfect character sets and the characters they contain.

A "WP String" differs from a word string in that it can have both 1 byte characters and 2 byte characters. This is accomplished by putting special 1 byte "gate" codes before and after the 2 byte character. The gate codes tell the reading program that the character is to be read as 2 bytes instead of 1. Only a single 2 byte character can be contained between the gate codes. If a second, third, fourth, etc., 2 byte character is needed it must have the gate codes before and after it as well. This makes each 2 byte character 4 bytes long (including the 2 gates). 1 byte, or standard characters are coded the way they normally would be in any string. The WP String is always terminated with a 1 byte null value.

For the value and coding of 2 byte characters with their gate codes, refer to the WordPerfect 8 File Format documentation in the SDK.

General .SET File Format

The format of the WPC8.SET, and product specific .SET files are exactly the same as a WordPerfect 8 document. The printer information is stored as data packets in the file's prefix area. For a complete description of the overall document file format, refer to the WordPerfect 8 File Format documentation in the SDK.

Packet Types for Printer Information

Packet Type Value	Packet

1	Printer List Packet

254 (0xFE)	Default Printer Packet

Packet type 1 is contained in the WPC8.SET file. Packet 254 (0xFE) is contained in the WordPerfect Corp. product specific .SET file.

Packet Type 1 Printer List Packet

The format of the "Default Printer Packet" is repeated for each printer listed in this packet. See "Packet Type 254 (0xFE) Default Printer Packet" documentation below for the format of each of the printers listed in this packet.

Packet Type 254 (0xFE) Default Printer Packet

All fields are fixed length. For strings, word strings, and WP strings that are shorter than the listed size, the extra bytes are padded with zeros.

[Standard printer name (word string)] x 38

[changed printer name (word string)] x 38

[.PRS filename (word string)] x 13

<Reserved (used by WordPerfect only)> x 160

[initial font face name (word string)] x 38

[initial font style (word string)] x 38

{initial font point size in 3600ths of an inch}

<initial font type (.PRS = 0, ATM = 1)>

<flags>

Bit	Meaning

0	printer is selected

1	initialize printer when wp starts

<more flags>

Bit	Meaning

0	prompt for filename

1	system/shared printer

2	check initial printer status

3	initialize serial port

4	configured for color printing

5	color capable printer

6	check default printer?

7	does not support graphics

<output bin flags>

Bit	Meaning

0	printer supports sorting

1	printer supports grouping

2	printer supports offset joggers

3	default to offset joggers on

{output bin selected (bit 0 = bin1, bit 1 = bin2, etc.)}

<destination type>

Value	Meaning

0	print to disk type

2	dedicated device type

3	spooled with wpp in lpr printcap file

4	spooled with wpp in lp filter

7	custom spool command

9	spooled with wpp in the AIX qconfig file

11 (0x0B)	UNIX only lp spooler

12 (0x0C)	UNIX only lpr spooler

13 (0x0D)	UNIX only aix spooler

254 (0xFE)	Other

255 (0xFF)	no type

<Reserved (used by WordPerfect)> x 4

<destination description (WP String)> x 41

<Spooler String> x 160

If "Destination Type" equals:	Type of String Data Stored:

0	Path and Filename to print to

2	Device Name

3	Nothing (Null terminator only)

4	Nothing (Null terminator only)

7	Nothing (Null terminator only)

9	Nothing (Null terminator only)

11 (0x0B)	Additional user supplied spooler options

12 (0x0C)	Additional user supplied spooler options

13 (0x0D)	Additional user supplied spooler options

254 (0xFE)	Nothing (Null terminator only)

255 (0xFF)	Nothing (Null terminator only)

{date and time printer created}

<downloadable fonts/printer command path> x 160

<language of .ALL/.PRS file (ie. "us")> x 3