The PDF output from this function is based on the ASCII output created with toString()
.
Usage
export_as_pdf(
x,
file,
page_type = "letter",
landscape = FALSE,
pg_width = page_dim(page_type)[if (landscape) 2 else 1],
pg_height = page_dim(page_type)[if (landscape) 1 else 2],
width = lifecycle::deprecated(),
height = lifecycle::deprecated(),
margins = c(4, 4, 4, 4),
min_siblings = 2,
font_family = "Courier",
font_size = 8,
fontsize = font_size,
lineheight = 1.2,
paginate = TRUE,
page_num = default_page_number(),
lpp = NULL,
cpp = NULL,
hsep = "-",
indent_size = 2,
rep_cols = NULL,
tf_wrap = TRUE,
max_width = NULL,
colwidths = NULL,
fontspec = font_spec(font_family, font_size, lineheight),
ttype_ok = FALSE
)
Arguments
- x
(
ANY
)
a table-like object to export. Must have an applicablematrix_form
method.- file
(
string
)
file to write to, must have.pdf
extension.- page_type
(
string
)
name of a page type. Seepage_types
. Ignored whenpg_width
andpg_height
are set directly.- landscape
(
flag
)
whether the dimensions ofpage_type
should be inverted for landscape orientation. Defaults toFALSE
, ignored whenpg_width
andpg_height
are set directly.- pg_width
(
numeric(1)
)
page width in inches.- pg_height
(
numeric(1)
)
page height in inches.- width
Please use the
pg_width
argument or specifypage_type
instead.- height
Please use the
pg_height
argument or specifypage_type
instead.- margins
(
numeric(4)
)
the number of lines/characters of the margin on the bottom, left, top, and right sides of the page, respectively.- min_siblings
(
numeric
)
minimum sibling rows which must appear on either side of pagination row for a mid-subtable split to be valid. Defaults to 2 for tables. It is automatically turned off (set to 0) for listings.- font_family
(
string
)
name of a font family. An error will be thrown if the family named is not monospaced. Defaults to"Courier"
.- font_size
(
numeric(1)
)
font size. Defaults to12
.- fontsize
- lineheight
(
numeric(1)
)
line height. Defaults to1
.- paginate
(
flag
)
whether pagination should be performed. Defaults toTRUE
if page size is specified (including the default).- page_num
(
string
)
placeholder string for page numbers. See default_page_number for more information. Defaults toNULL
.- lpp
(
numeric(1)
orNULL
)
lines per page. IfNA
(the default), this is calculated automatically based on the specified page size).NULL
indicates no vertical pagination should occur.- cpp
(
numeric(1)
orNULL
)
width (in characters) per page. IfNA
(the default), this is calculated automatically based on the specified page size).NULL
indicates no horizontal pagination should occur.- hsep
(
string
)
character to repeat to create header/body separator line. IfNULL
, the object value will be used. If" "
, an empty separator will be printed. Seedefault_hsep()
for more information.- indent_size
(
numeric(1)
)
indent size, in characters. Ignored whenx
is already aMatrixPrintForm
object in favor of information there.- rep_cols
(
numeric(1)
)
number of columns (not including row labels) to be repeated on every page. Defaults to 0.- tf_wrap
(
flag
)
whether the text for title, subtitles, and footnotes should be wrapped.- max_width
(
integer(1)
,string
orNULL
)
width that title and footer (including footnotes) materials should be word-wrapped to. IfNULL
, it is set to the current print width of the session (getOption("width")
). If set to"auto"
, the width of the table (plus any table inset) is used. Parameter is ignored iftf_wrap = FALSE
.- colwidths
(
numeric
)
vector of column widths (in characters) for use in vertical pagination.- fontspec
(
font_spec
)
a font_spec object specifying the font information to use for calculating string widths and heights, as returned byfont_spec()
.- ttype_ok
(
logical(1)
)
should truetype (non-monospace) fonts be allowed viafontspec
. Defaults toFALSE
. This parameter is primarily for internal testing and generally should not be set by end users.
Details
By default, pagination is performed with default cpp
and lpp
defined by specified page
dimensions and margins. User-specified lpp
and cpp
values override this, and should
be used with caution.
Title and footer materials are also word-wrapped by default (unlike when printed to the
terminal), with cpp
(as defined above) as the default max_width
.
Examples
if (FALSE) { # \dontrun{
tf <- tempfile(fileext = ".pdf")
export_as_pdf(basic_matrix_form(mtcars), file = tf, pg_height = 4)
tf <- tempfile(fileext = ".pdf")
export_as_pdf(basic_matrix_form(mtcars), file = tf, lpp = 8)
} # }