Skip to contents

Draws a ggplot to a PNG (through ragg when installed, otherwise the cairo png() device with a warning), embeds it in an RTF file, and applies the same page, header, title block, footnotes and source line as tlf_rtf_table().

Usage

tlf_rtf_figure(plot, file, titles = NULL, config = NULL, render = NULL)

Arguments

plot

A ggplot, typically from tlf_build_figure().

file

Output .rtf path.

titles

A tlf_titles() object, a character vector, or NULL.

config

A tlf_config(); NULL resolves through tlf_get_config().

render

A tlf_render_opts() overriding the configured policy.

Value

file, invisibly.

Details

By default the render runs in an isolated child process with bounded retries (see tlf_run_isolated() and tlf_render_opts()). A native crash in the graphics stack then cannot kill the calling session. Isolation contains most crashes, but not all of them: font operations in the parent process can still fault on an affected host.

Examples

# \donttest{
p <- fig_meanci(ex_adlb[ex_adlb$PARAMCD == "ALT", ])
f <- tempfile(fileext = ".rtf")
tlf_rtf_figure(p, f, titles = tlf_titles("Mean ALT by Visit", type = "Figure",
                                         number = "14.3.1"),
               render = tlf_render_opts(isolate = FALSE))
unlink(f)
# }