preparePdf: Open PDF Device with DIN A4 Dimensions by Default

View source: R/pdf.R

preparePdfR Documentation

Open PDF Device with DIN A4 Dimensions by Default

Description

Opens a PDF device in A4 paper format. After calling this function all plots go into the specified PDF file in pdfFile. Important: The PDF file needs to be closed explicitely with grDevices::dev.off() after all desired plots have been made.

Usage

preparePdf(
  pdfFile = tempfile(fileext = ".pdf"),
  landscape = TRUE,
  borderWidth.cm = 2,
  borderHeight.cm = 2,
  width.cm = NULL,
  height.cm = NULL,
  makeCurrent = TRUE,
  paper = NULL,
  ...
)

Arguments

pdfFile

Full path to PDF file to be created

landscape

If TRUE (default), orientation in PDF file will be landscape, else portrait

borderWidth.cm

(Total) border width in "width" direction in cm

borderHeight.cm

(Total) border width in "height" direction in cm

width.cm

page width in cm. Default according to DIN A4

height.cm

page height in cm. Default according to DIN A4

makeCurrent

if TRUE (default), the opened PDF device will become the current device, otherwise the current device will be restored

paper

passed to pdf. By default "A4" (if landscape = FALSE) or "A4r" (if landscape = TRUE). Use paper = "special" to use the dimensions of the plot.

...

further arguments passed to pdf

Value

full path to pdf file

See Also

finishAndShowPdf

Examples

## Not run: 
# Open PDF file by giving a path to preparePdf(). The path is returned.
pdf_file <- preparePdf(file.path(tempdir(), "example_preparePdf.pdf"))

# Plot something
plot(x <- seq(-pi,pi,pi/100), sin(x), type = "l")

# Open PDF file in viewer
finishAndShowPdf(pdf_file)

## End(Not run)


KWB-R/kwb.utils documentation built on April 1, 2024, 7:12 a.m.