File: save_as_image.Rd

package info (click to toggle)
r-cran-flextable 0.8.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,264 kB
  • sloc: sh: 15; makefile: 2
file content (67 lines) | stat: -rw-r--r-- 2,037 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/printers.R
\name{save_as_image}
\alias{save_as_image}
\title{save a flextable as an image}
\usage{
save_as_image(x, path, zoom = 3, expand = 10, webshot = "webshot")
}
\arguments{
\item{x}{a flextable object}

\item{path}{image file to be created. It should end with .png, .pdf, or .jpeg.}

\item{zoom, expand}{parameters used by \code{webshot} function.}

\item{webshot}{webshot package as a scalar character, one of "webshot" or
"webshot2".}
}
\description{
save a flextable as a png, pdf or jpeg image.

Image generated with package 'webshot' or package 'webshot2'.
\strong{Package 'webshot2' should be prefered} as 'webshot' can have
issues with some properties (i.e. bold are not rendered for some users).

The image is coming from a screenshot of the 'HTML' output.
\code{save_as_image()} is a tool to make life easier for users.
Nevertheless, the features have some limitations that can't
be solved with flextable because they are not related to
flextable:
\itemize{
\item \code{png} does support transparency,
\item \code{jpeg} does not support transparency,
\item webshot2 does not allow transparent background,
\item webshot does allow transparent background.
}
}
\note{
This function requires package webshot or webshot2.
The screenshot process is rather slow because it is managed by
an external program (see webshot or webshot2 documentation).
}
\examples{
ft <- flextable(head(mtcars))
ft <- autofit(ft)
tf <- tempfile(fileext = ".png")
\dontrun{
if (require("webshot")) {
  save_as_image(x = ft, path = "myimage.png")
}
}
}
\seealso{
Other flextable print function: 
\code{\link{as_raster}()},
\code{\link{df_printer}()},
\code{\link{flextable_to_rmd}()},
\code{\link{gen_grob}()},
\code{\link{htmltools_value}()},
\code{\link{knit_print.flextable}()},
\code{\link{plot.flextable}()},
\code{\link{print.flextable}()},
\code{\link{save_as_docx}()},
\code{\link{save_as_html}()},
\code{\link{save_as_pptx}()}
}
\concept{flextable print function}