lpr(x, command="lpr", width=80, length=66, wait=F, rm.file=T,
...)
A convenient way to customize lpr is to write a wrapper function for it. Ask your local S-PLUS administrator, or see the examples.
lpr(my.function, command="lpr -Pfred")
# Assumes the UNIX lpr command accepts ASCII files.
# Will send to printer "fred".
# The next examples assume that the printer understands only PostScript,
# and that the UNIX command to print an ASCII file is enscript,
# available as part of the Transcript software from Adobe Systems.
lpr(x, command="enscript -B", width=90, length=64)
# assumes default font size is 10 point
lpr(x, command="grace enscript -B <", width=90, length=64)
# if enscript is installed only on remote host "grace"
lpr(x, command="enscript -r -B", width=125, length=49)
# landscape (horizontal) orientation
# The following is an example of a wrapper function for lpr using
# enscript.
lpr.enscript <-
function(x, header = NULL, landscape = F, columns = 1,
font = if(columns == 2) "Courier7" else "Courier10", width,
length, ...)
{
# front-end to S-PLUS lpr function, for Adobe's enscript program.
# 'width' and 'length' in this function refer to the printed page,
# and include the header. Default values will not be correct for other
# font sizes.
if(missing(width))
width <- if(columns == 2)
ifelse(landscape, 89, 66)
else if(columns == 1)
ifelse(landscape, 125, 90)
else
stop("columns must be 1 or 2")
if(missing(length))
length <- if(columns == 2)
ifelse(landscape, 67, 90)
else
ifelse(landscape, 49, 66)
if(is.null(header))
header <- paste(deparse(substitute(x)), " ", date())
header <- paste(sep = "", "'-b\"", header, "\"'")
orient <- if(landscape) "-r" else ""
col.flag <- paste("-", columns, sep = "")
font <- paste("-f", font, sep = "")
command <- paste("enscript -q", header, orient, col.flag, font,
"<")
invisible(lpr(x, command = command, width = width - 2,
length = length - 2, ...))
}