Title: | Render Slides to Different Formats |
---|---|
Description: | Render slides to different formats, including 'html', 'pdf', 'png', 'gif', 'pptx', and 'mp4', as well as a 'social' output, a 'png' of the first slide re-sized for sharing on social media. |
Authors: | John Helveston [aut, cre, cph]
|
Maintainer: | John Helveston <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.1 |
Built: | 2024-08-31 03:05:26 UTC |
Source: | https://github.com/jhelvy/renderthis |
Build slides to multiple outputs. Options are "html"
, "social"
"pdf"
,
"png"
, "gif"
, "mp4"
, and "pptx"
. See each individual build_*()
function for details about each output type.
build_all( input, include = c("html", "social", "pdf", "png", "gif", "mp4", "pptx"), exclude = NULL, complex_slides = FALSE, partial_slides = FALSE, delay = 1, density = 100, slides = "all", fps = 1 )
build_all( input, include = c("html", "social", "pdf", "png", "gif", "mp4", "pptx"), exclude = NULL, complex_slides = FALSE, partial_slides = FALSE, delay = 1, density = 100, slides = "all", fps = 1 )
input |
Path to an |
include |
A vector of the different output types to build. Options are
|
exclude |
A vector of the different output types to NOT build. Options
are |
complex_slides |
For "complex" slides (e.g. slides with panelsets or
other html widgets or advanced features), set |
partial_slides |
Should partial (continuation) slides be included in the
output? If |
delay |
Seconds of delay between advancing to and printing a new slide.
Only used if |
density |
Resolution of the resulting PNGs in each slide file. Defaults
to |
slides |
A numeric or integer vector of the slide number(s) to render
as PNG files , or one of |
fps |
Frames per second of the resulting |
Builds slides to multiple output formats.
if (interactive()) { # Both of these build html and pdf outputs # (PDF outputs require Google Chrome for {pagedown}) with_example("slides.Rmd", requires_chrome = TRUE, { build_all("slides.Rmd", include = c("html", "pdf")) }) }
if (interactive()) { # Both of these build html and pdf outputs # (PDF outputs require Google Chrome for {pagedown}) with_example("slides.Rmd", requires_chrome = TRUE, { build_all("slides.Rmd", include = c("html", "pdf")) }) }
Render slides as a GIF video file. The function renders to the PDF, converts each slide in the PDF to a PNG, and then converts the deck of PNG files to a GIF file.
to_gif( from, to = NULL, density = 100, slides = "all", fps = 1, complex_slides = FALSE, partial_slides = FALSE, delay = 1, keep_intermediates = FALSE )
to_gif( from, to = NULL, density = 100, slides = "all", fps = 1, complex_slides = FALSE, partial_slides = FALSE, delay = 1, keep_intermediates = FALSE )
from |
Path to an |
to |
Name of the output |
density |
Resolution of the resulting PNGs in each slide file. Defaults
to |
slides |
A numeric or integer vector of the slide number(s) to include
in the GIF, or one of |
fps |
Frames per second in the animated GIF. |
complex_slides |
For "complex" slides (e.g. slides with panelsets or
other html widgets or advanced features), set |
partial_slides |
Should partial (continuation) slides be included in the
output? If |
delay |
Seconds of delay between advancing to and printing a new slide.
Only used if |
keep_intermediates |
Should we keep the intermediate files used to
render the final output? The default is |
Slides are rendered as a .gif
file.
with_example("slides.Rmd", requires_chrome = TRUE, { # Render gif from Rmd, html, pdf, or direct URL to_gif("slides.Rmd") })
with_example("slides.Rmd", requires_chrome = TRUE, { # Render gif from Rmd, html, pdf, or direct URL to_gif("slides.Rmd") })
Render xaringan or Quarto slides as an html file. In generally, it is the
same thing as rmarkdown::render()
or quarto::quarto_render()
except that
the self_contained
option is forced to TRUE
if the HTML file is built
into a directory other than the one containing from
.
to_html(from, to = NULL, self_contained = FALSE, render_args = NULL)
to_html(from, to = NULL, self_contained = FALSE, render_args = NULL)
from |
Path to an |
to |
The name of the output file. If using |
self_contained |
Should the output file be a self-contained HTML file
where all images, CSS and JavaScript are included directly in the output
file? This option, when |
render_args |
A list of arguments passed to |
Slides are rendered as an .html
file.
with_example("slides.Rmd", { # Render html from Rmd file to_html("slides.Rmd") })
with_example("slides.Rmd", { # Render html from Rmd file to_html("slides.Rmd") })
Render slides as an MP4 video file. The function renders to the pdf, converts each slide in the pdf to a png, and then converts the deck of png files to a MP4 video file.
to_mp4( from, to = NULL, density = 100, slides = "all", fps = 1, complex_slides = FALSE, partial_slides = FALSE, delay = 1, keep_intermediates = FALSE )
to_mp4( from, to = NULL, density = 100, slides = "all", fps = 1, complex_slides = FALSE, partial_slides = FALSE, delay = 1, keep_intermediates = FALSE )
from |
Path to an |
to |
Name of the output |
density |
Resolution of the resulting PNGs in each slide file. Defaults
to |
slides |
A numeric or integer vector of the slide number(s) to include
in the mp4, or one of |
fps |
Frames per second of the resulting |
complex_slides |
For "complex" slides (e.g. slides with panelsets or
other html widgets or advanced features), set |
partial_slides |
Should partial (continuation) slides be included in the
output? If |
delay |
Seconds of delay between advancing to and printing a new slide.
Only used if |
keep_intermediates |
Should we keep the intermediate files used to
render the final output? The default is |
Slides are rendered as an .mp4
file.
with_example("slides.Rmd", requires_chrome = TRUE, requires_packages = "av", { # Render mp4 from Rmd, html, pdf, or direct URL to_mp4("slides.Rmd") })
with_example("slides.Rmd", requires_chrome = TRUE, requires_packages = "av", { # Render mp4 from Rmd, html, pdf, or direct URL to_mp4("slides.Rmd") })
Render slides as a PDF file. Requires a local installation of Chrome.
If you set complex_slides = TRUE
or partial_slides = TRUE
, you will also
need to install the chromote and pdftools packages.
to_pdf( from, to = NULL, complex_slides = FALSE, partial_slides = FALSE, delay = 1, keep_intermediates = NULL )
to_pdf( from, to = NULL, complex_slides = FALSE, partial_slides = FALSE, delay = 1, keep_intermediates = NULL )
from |
Path to an |
to |
The name of the output |
complex_slides |
For "complex" slides (e.g. slides with panelsets or
other html widgets or advanced features), set |
partial_slides |
Should partial (continuation) slides be included in the
output? If |
delay |
Seconds of delay between advancing to and printing a new slide.
Only used if |
keep_intermediates |
Should we keep the intermediate HTML file? Only
relevant if the |
Slides are rendered as a .pdf
file.
with_example("slides.Rmd", requires_chrome = TRUE, { # Render pdf from Rmd, html, or direct URL to_pdf("slides.Rmd") })
with_example("slides.Rmd", requires_chrome = TRUE, { # Render pdf from Rmd, html, or direct URL to_pdf("slides.Rmd") })
Render PNG image(s) of slides. The function renders to the PDF and
then converts it into PNG files of each slide. The slide numbers defined by
the slides
argument are saved (defaults to 1
, returning only the title
slide). If length(slides) > 1
, it will return the PNG files in a ZIP file.
You can also get a ZIP file of all the slides as PNGs by setting slides = "all"
).
to_png( from, to = NULL, density = 100, slides = 1, complex_slides = FALSE, partial_slides = FALSE, delay = 1, keep_intermediates = FALSE )
to_png( from, to = NULL, density = 100, slides = 1, complex_slides = FALSE, partial_slides = FALSE, delay = 1, keep_intermediates = FALSE )
from |
Path to an |
to |
Name of the output |
density |
Resolution of the resulting PNGs in each slide file. Defaults
to |
slides |
A numeric or integer vector of the slide number(s) to render
as PNG files , or one of |
complex_slides |
For "complex" slides (e.g. slides with panelsets or
other html widgets or advanced features), set |
partial_slides |
Should partial (continuation) slides be included in the
output? If |
delay |
Seconds of delay between advancing to and printing a new slide.
Only used if |
keep_intermediates |
Should we keep the intermediate files used to
render the final output? The default is |
Slides are rendered as a .png
file (single) or .zip
file of
multiple .png
files.
with_example("slides.Rmd", requires_chrome = TRUE, { # By default a png of only the first slide is built to_png("slides.Rmd", keep_intermediates = TRUE) # or render a zip file of multiple or all slides (`slides = "all"`) to_png("slides.pdf", slides = c(1, 3, 5)) })
with_example("slides.Rmd", requires_chrome = TRUE, { # By default a png of only the first slide is built to_png("slides.Rmd", keep_intermediates = TRUE) # or render a zip file of multiple or all slides (`slides = "all"`) to_png("slides.pdf", slides = c(1, 3, 5)) })
Render slides as a .pptx
file. The function renders to the PDF and
then converts it into PNG images that are inserted on each slide in the
PowerPoint file.
to_pptx( from, to = NULL, density = 100, slides = "all", complex_slides = FALSE, partial_slides = FALSE, delay = 1, keep_intermediates = FALSE, ratio = NULL )
to_pptx( from, to = NULL, density = 100, slides = "all", complex_slides = FALSE, partial_slides = FALSE, delay = 1, keep_intermediates = FALSE, ratio = NULL )
from |
Path to an |
to |
Name of the output |
density |
Resolution of the resulting PNGs in each slide file. Defaults
to |
slides |
A numeric or integer vector of the slide number(s) to include
in the pptx, or one of |
complex_slides |
For "complex" slides (e.g. slides with panelsets or
other html widgets or advanced features), set |
partial_slides |
Should partial (continuation) slides be included in the
output? If |
delay |
Seconds of delay between advancing to and printing a new slide.
Only used if |
keep_intermediates |
Should we keep the intermediate files used to
render the final output? The default is |
ratio |
PowerPoint slides ratio. Possible values are
|
Slides are rendered as a pptx file.
with_example("slides.Rmd", requires_chrome = TRUE, requires_packages = "officer", { # Render pptx from Rmd, html, pdf, or direct URL to_pptx("slides.Rmd") })
with_example("slides.Rmd", requires_chrome = TRUE, requires_packages = "officer", { # Render pptx from Rmd, html, pdf, or direct URL to_pptx("slides.Rmd") })
Render png image of first slide for sharing on social media.
Requires a local installation of Chrome as well as the webshot2 package:
remotes::install_github("rstudio/webshot2")
.
to_social(from, to = NULL)
to_social(from, to = NULL)
from |
Path to Rmd file of input media (e.g., xaringan slides). |
to |
The name of the output file. If using NULL then the output filename
will be based on filename for the |
Slides are rendered as a png file.
if (interactive()) { with_example("slides.Rmd", requires_chrome = TRUE, requires_packages = "webshot2", { # Render png image of first slide from Rmd file # sized for sharing on social media to_social("slides.Rmd") }) }
if (interactive()) { with_example("slides.Rmd", requires_chrome = TRUE, requires_packages = "webshot2", { # Render png image of first slide from Rmd file # sized for sharing on social media to_social("slides.Rmd") }) }