Rev 33769 | Rev 35352 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{pdf}\alias{pdf}\title{PDF Graphics Device}%% The definitive doc is the source :-)%% ../../../main/devices.c & ../../../main/devPS.c\description{\code{pdf} starts the graphics device driver for producing PDFgraphics.}\synopsis{pdf(file = ifelse(onefile, "Rplots.pdf", "Rplot\%03d.pdf"),width = 6, height = 6, onefile = TRUE, family,title = "R Graphics Output", fonts = NULL, version = "1.1",paper = "special", \dots)}\usage{pdf(file = ifelse(onefile, "Rplots.pdf", "Rplot\%03d.pdf"),width = 6, height = 6, onefile = TRUE, family = "Helvetica",title = "R Graphics Output", fonts = NULL, version = "1.1",paper, encoding, bg, fg, pointsize)}\arguments{\item{file}{a character string giving the name of the file.}\item{width, height}{the width and height of the graphics region ininches.}\item{onefile}{logical: if true (the default) allow multiple figuresin one file. If false, generate a file name containing the pagenumber.}\item{family}{the font family to be used, one of \code{"AvantGarde"},\code{"Bookman"}, \code{"Courier"}, \code{"Helvetica"},\code{"Helvetica-Narrow"}, \code{"NewCenturySchoolbook"},\code{"Palatino"} or \code{"Times"}. \bold{Note} the otherspecifications allowed for \code{\link{postscript}} are \bold{not}available.}\item{title}{title string to embed in the file.}\item{paper}{the size of paper in the printer. The choices are\code{"a4"}, \code{"letter"}, \code{"legal"} and\code{"executive"} (and these can be capitalized).The default is \code{"special"}, which means that the \code{width}and \code{height} specify the paper size. A further choice is\code{"default"}; if this is selected, thepapersize is taken from the option \code{"papersize"}if that is set and to \code{"a4"} if it is unset or empty.}\item{encoding}{the name of an encoding file. Defaults to#ifdef unix\code{"ISOLatin1.enc"}#endif#ifdef windows\code{"WinAnsi.enc"}#endifin the \file{R\_HOME/afm} directory, which is used if the path doesnot contain a path separator. An extension \code{".enc"} can beomitted.#ifdef unixIn a UTF-8 locale only \code{"ISOLatin1.enc"} is allowed.#endif}\item{pointsize}{the default point size to be used.}\item{bg}{the default background color to be used.}\item{fg}{the default foreground color to be used.}\item{fonts}{a character vector specifying device-independentR graphics font family names for fontswhich will be included in the PDF file.}\item{version}{a string describing the PDF version that will beused to produce output.}}\details{\code{pdf()} opens the file \code{file} and the PDF commands needed toplot any graphics requested are sent to that file.The \code{family} argument can be used to specify either adevice-independent R graphics font family (see\code{postscriptFonts}) or a PDF-specificfont family as the initial/default font for the device.If a device-independent R graphics font family is specified(e.g., via \code{par(family=)} in the graphics package),the PDF device makes use of the PostScript font mappings toconvert the R graphics font familyto a PDF-specific font family description. R does \emph{not}embed fonts in the PDF file though, so it is only possible touse mappings to the font families that areassumed to be available in a PDF viewer: \code{"Times"} or\code{"Times New Roman"},\code{"Helvetica"} or \code{"Arial"}, \code{"Courier"},\code{"Symbol"}, and \code{"ZapfDingbats"}.See \code{\link{postscript}} for details of encodings, as the internalcode is shared between the drivers. The native PDF encoding is givenin file \file{PDFDoc.enc}.\code{pdf} writes uncompressed PDF. It is primarily intended forproducing PDF graphics for inclusion in other documents, andPDF-includers such as \code{pdftex} are usually able to handlecompression.At present the PDF is fairly simple, with each page being representedas a single stream. The \R graphics model does not distinguishgraphics objects at the level of the driver interface.The \code{version} argument modifies the sort of PDF code thatgets produced. At the moment this only concerns the production oftransparent output. The version must be greater than 1.4 fortransparent output to be produced. Specifying a lower versionnumber may be useful if you want to produce PDF output that can beviewed on older PDF viewers.Line widths as controlled by \code{par(lwd=)} are in multiples of1/96inch. Multiples less than 1 are allowed. \code{pch="."} with\code{cex = 1} corresponds to a square of side 1/72 inch.}\note{Acrobat Reader does not use the fonts specified but rather emulatesthem from multiple-master fonts. This can be seen in imprecisecentering of characters, for example the multiply and divide signs inHelvetica.}\seealso{\code{\link{postscriptFonts}},\code{\link{Devices}},\code{\link{postscript}}}\examples{\dontrun{## Test function for encodingsTestChars <- function(encoding="ISOLatin1", ...){pdf(encoding=encoding, ...)par(pty="s")plot(c(-1,16), c(-1,16), type="n", xlab="", ylab="", xaxs="i", yaxs="i")title(paste("Centred chars in encoding", encoding))grid(17, 17, lty=1)for(i in c(32:255)) {x <- i %% 16y <- i %/% 16points(x, y, pch=i)}dev.off()}## there will be many warnings.TestChars("ISOLatin2")## doesn't view properly in US-spec Acrobat 5.05, but gs7.04 works.## Lots of characters are not centred.}}\keyword{device}