Solaris Common Desktop Environment: Programmer's Guide

Partial Print Integration

To do partial print integration, your application must provide a print action. The extent to which printing is integrated depends on which, if any, of the printing environment variables are handled by the action

Providing the Print Command for Partial Integration

To provide partial print integration, your application must provide a print command line of the form:

print_command[options]-filefilename

where options provides a mechanism for dereferencing none, some, or all of the printing environment variables (see "Desktop Printing Environment Variables" ).

The simplest form of this print command line omits options.

print_command -filefilename

This command line lets users print your application's data files using the desktop printer drop zones. However, printing destination is not set by the drop zone. In addition, other print behaviors set by the environment variables are not implemented. For example, the desktop may not be able to direct silent printing or remove temporary files.

If your print command line provides additional command-line options that correspond to the desktop printing environment variables, you can provide additional integration.

For example, the following command line provides the ability to dereference LPDEST:

print_command
[-d destination] [-filefilename]

where:

destination is the destination printer.

The next print command line provides options for dereferencing all four variables:

print_command [-d destination] [-u user_file_name] [-s] [-e] -filefilename

where:

user_file_name

Indicates the file name as seen by the user. 

-s

Printing is silent (no Print dialog box is displayed). 

-e

Removes the file after it is printed. 

The dereferencing occurs in the action definition. See the section, "Desktop Printing Environment Variables" for more information.

Turning Environment Variables into Command-Line Switches

If your action is not capable of dereferencing the four environment variables, but it is capable of taking corresponding command-line options, this subsection explains how to turn the environment variable values into command-line options.

For example, this is a simple print action that deferences LPDEST:

ACTION Print
{
		ARG_TYPE				data_type
		EXEC_STRING				print_command -d $LPDEST -file %(file)Arg_1% 
}

However, this print action may create unpredictable behavior if LPDEST is not set.

One way to create a Print action that provides proper behavior when variables are not set is to create a shell script that is used by the Print action.

For example, the following action and the script it uses properly handle all four environment variables:

ACTION Print	
{
		ARG_TYPE				data_type
		EXEC_STRING			app_root/bin/envprint %(File)Arg_1%
}

The contents of the envprint script follow:

#!/bin/sh
# envprint - sample print script 
DEST="" 
USERFILENAME=""
REMOVE="" 
SILENT=""  

if [ $LPDEST ] ; then
		DEST="-d $LPDEST" 
fi  

if [ $DTPRINTUSERFILENAME ] ; then
		USERFILENAME="-u $DTPRINTUSERFILENAME" 
fi  

DTPRINTFILEREMOVE=echo $DTPRINTFILEREMOVE | tr "[:upper:]" "[:lower:]"` 
if [ "$DTPRINTFILEREMOVE" = "true" ] ; then
		REMOVE="-e" 
fi  

DTPRINTSILENT=`echo $DTPRINTSILENT | tr

"[:upper:]" "[:lower:]"` if [

"$DTPRINTSILENT" = "true" ] ; then
		SILENT="-s" 
fi  

print_command $DEST $USERFILENAME $REMOVE $SILENT -file $1