Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/davidgohel/flextable/llms.txt

Use this file to discover all available pages before exploring further.

save_as_image() exports a single flextable to a PNG or SVG file using R’s graphics system.
Captions are not part of the table image. When exporting to PNG or SVG, the caption set by set_caption() is not included. Captions are intended for document outputs such as Word, HTML, or PDF.

Function signature

save_as_image(x, path, expand = 10, res = 200, ...)

Parameters

x
flextable
required
A flextable object.
path
string
required
Path to the output file. Must end with .png or .svg.
expand
numeric
default:"10"
Amount of whitespace (in pixels) to add around the table.
res
numeric
default:"200"
Resolution of the output device in DPI.
...
Unused arguments.

Return value

A string containing the full path of the generated file.

Examples

library(gdtools)
register_liberationsans()
set_flextable_defaults(font.family = "Liberation Sans")

ft <- flextable(head(mtcars))
ft <- autofit(ft)
tf <- tempfile(fileext = ".png")
save_as_image(x = ft, path = tf)

init_flextable_defaults()

See also

Build docs developers (and LLMs) love