-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathrenderthis.Rmd
More file actions
147 lines (104 loc) · 4.48 KB
/
renderthis.Rmd
File metadata and controls
147 lines (104 loc) · 4.48 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
---
title: "renderthis"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{renderthis}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
eval = FALSE,
collapse = TRUE,
comment = "#>"
)
```
## Overview
```{r child="../man/fragments/usage.Rmd"}
```
## Render HTML
Render an HTML file from an `.Rmd` file of xaringan slides or `.qmd` of Quarto revealjs slides:
```{r}
to_html(from = "slides.Rmd")
to_html(from = "slides.qmd")
```
## Render PDF
Input can be an `.Rmd` file, `.qmd` file, `.html` file, or url:
```{r}
to_pdf(from = "slides.Rmd")
to_pdf(from = "slides.qmd")
to_pdf(from = "slides.html")
to_pdf(from = "https://jhelvy.github.io/renderthis/example/slides.html")
```
**Note**: Rendering the PDF requires a [local installation of Google Chrome](https://jhelvy.github.io/renderthis/articles/renderthis-setup.html#local-chrome-installation)
## Render GIF
Input can be an `.Rmd` file, `.qmd` file, `.html` file, `.pdf` file, or url:
```{r}
to_gif(from = "slides.Rmd")
to_gif(from = "slides.qmd")
to_gif(from = "slides.html")
to_gif(from = "slides.pdf")
to_gif(from = "https://jhelvy.github.io/renderthis/example/slides.html")
```
Example:
<img src="https://jhelvy.github.io/renderthis/example/slides.gif" width=500>
## Render MP4
Input can be an `.Rmd` file, `.qmd` file, `.html` file, `.pdf` file, or url:
```{r}
to_mp4(from = "slides.Rmd")
to_mp4(from = "slides.qmd")
to_mp4(from = "slides.html")
to_mp4(from = "slides.pdf")
to_mp4(from = "https://jhelvy.github.io/renderthis/example/slides.html")
```
## Render PPTX
Creates a pptx file where each slide contains a png image of each slide. While you won't be able to edit the content in the png(s) from Powerpoint, you can at least annotate it.
(See the [slidex](https://github.com/datalorax/slidex) package by @datalorax to do the opposite: pptx --> xaringan!)
Input can be an `.Rmd` file, `.qmd` file, `.html` file, `.pdf` file, or url:
```{r}
to_pptx(from = "slides.Rmd")
to_pptx(from = "slides.qmd")
to_pptx(from = "slides.html")
to_pptx(from = "slides.pdf")
to_pptx(from = "https://jhelvy.github.io/renderthis/example/slides.html")
```
## Render PNG
Render png image(s) of some or all slides. Use the `slides` argument to determine which slides to include (defaults to `1`, returning just the first slide).
Input can be an `.Rmd` file, `.qmd` file, `.html` file, `.pdf` file, or url:
```{r}
# By default, a png of only the first slide is built
to_png(from = "slides.Rmd", to = "title_slide.png")
to_png(from = "slides.qmd", to = "title_slide.png")
to_png(from = "slides.html", to = "title_slide.png")
to_png(from = "slides.pdf", to = "title_slide.png")
to_png(from =
"https://jhelvy.github.io/renderthis/example/slides.html",
to = "title_slide.png"
)
# Use the `slides` argument to control which slides get rendered into pngs
to_png(from = "slides.pdf", to = "first_slide.png", slides = "first")
to_png(from = "slides.pdf", to = "last_slide.png", slides = "last")
to_png(from = "slides.pdf", slides = c(1, 3, 5)) # Choose subsets of slides
to_png(from = "slides.pdf", slides = -1) # Negative indices remove slides
to_png(from = "slides.pdf", slides = "all")
```
Example:
<img src="https://jhelvy.github.io/renderthis/example/title_slide.png" width=500>
## Render Social
Render a png of the first slide from an `.Rmd` file of xaringan slides (Quarto slides not yet supported). Image is sized for sharing on social media (e.g. Twitter).
```{r}
to_social(from = "slides.Rmd")
```
**Note**: This option requires the [chromote](https://github.com/rstudio/chromote) and [pdftools](https://github.com/ropensci/pdftools) packages.
Example:
<img src="https://jhelvy.github.io/renderthis/example/title_social.png" width=500>
## "Complex" slides and partial / incremental slides
"Complex" slides are slides that contain [panelsets](https://pkg.garrickadenbuie.com/xaringanExtra/#/panelset) or other html widgets / advanced features that might not render well as a pdf. To render these on each slide, set `complex_slides = TRUE`.
If you want to render a new slide for each increment on [incremental slides](https://slides.yihui.org/xaringan/incremental.html#1), set `partial_slides = TRUE`.
These options are available as options in any of the functions that depend on rendering the pdf:
- `to_pdf()`
- `to_png()`
- `to_gif()`
- `to_mp4()`
- `to_pptx()`
**Note**: These options require the [chromote](https://github.com/rstudio/chromote) and [pdftools](https://github.com/ropensci/pdftools) packages.