\HeaderA{pdf}{PDF Graphics Device}{pdf}
\keyword{device}{pdf}
\begin{Description}\relax
\code{pdf} starts the graphics device driver for producing PDF
graphics.
\end{Description}
\begin{Usage}
\begin{verbatim}
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",
    encoding, bg, fg, pointsize)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{file}] a character string giving the name of the file.
\item[\code{width, height}] the width and height of the graphics region in
inches.
\item[\code{onefile}] logical: if true (the default) allow multiple figures
in one file.  If false, generate a file name containing the page
number.
\item[\code{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 other
specifications allowed for \code{\LinkA{postscript}{postscript}} are \bold{not}
available.
\item[\code{title}] title string to embed in the file.
\item[\code{encoding}] the name of an encoding file.  Defaults to
\code{"ISOLatin1.enc"}
in the \file{R\_HOME/afm} directory, which is used if the path does
not contain a path separator.  An extension \code{".enc"} can be
omitted.
\item[\code{pointsize}] the default point size to be used.
\item[\code{bg}] the default background color to be used.
\item[\code{fg}] the default foreground color to be used.
\item[\code{fonts}] a character vector specifying device-independent
R graphics font family names for fonts
which will be included in the PDF file.
\item[\code{version}] a string describing the PDF version that will be
used to produce output.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{pdf()} opens the file \code{file} and the PDF commands needed to
plot any graphics requested are sent to that file.

The \code{family} argument can be used to specify either a
device-independent R graphics font family (see
\code{postscriptFonts}) or a PDF-specific
font 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 to
convert the R graphics font family
to a PDF-specific font family description.  R does \emph{not}
embed fonts in the PDF file though, so it is only possible to
use mappings to the font families that are
assumed 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{\LinkA{postscript}{postscript}} for details of encodings, as the internal
code is shared between the drivers.  The native PDF encoding is given
in file \file{PDFDoc.enc}.

\code{pdf} writes uncompressed PDF.  It is primarily intended for
producing PDF graphics for inclusion in other documents, and
PDF-includers such as \code{pdftex} are usually able to handle
compression.

At present the PDF is fairly simple, with each page being represented
as a single stream.  The \R{} graphics model does not distinguish
graphics objects at the level of the driver interface.

The \code{version} argument modifies the sort of PDF code that
gets produced.  At the moment this only concerns the production of
transparent output.  The version must be greater than 1.4 for
transparent output to be produced.  Specifying a lower version
number may be useful if you want to produce PDF output that can be
viewed on older PDF viewers.
\end{Details}
\begin{Note}\relax
Acrobat Reader does not use the fonts specified but rather emulates
them from multiple-master fonts.  This can be seen in imprecise
centering of characters, for example the multiply and divide signs in
Helvetica.
\end{Note}
\begin{SeeAlso}\relax
\code{\LinkA{postscriptFonts}{postscriptFonts}},
\code{\LinkA{Devices}{Devices}},
\code{\LinkA{postscript}{postscript}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## Not run: 
## Test function for encodings
TestChars <- 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 
        y <- i 
        points(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.
## End(Not run)\end{ExampleCode}
\end{Examples}

