如何将R reveal.js演示文稿转换为PDF格式?

piy*_*ush 7 pdf r rstudio r-markdown reveal.js

我在R中做了一个演示,使用了reveal.js模板之一(使用revealjs R包).

默认情况下,它生成一个html文件,当打开它进行演示时,它显示浏览器的顶部部分,包括书签,文件路径等...我可以关闭书签栏而不是文件路径部分,我需要在正式设置中显示这个将演示文稿导出为pdf似乎是一个更好的选择.

有谁知道如何将其导出为PDF格式?我可以在YAML标题中添加任何内容,以便输出为pdf而不是html吗?

下面是示例代码,它生成"test.html"文件.我想生成"test.pdf",同时保留演示文稿的所有其他属性,例如转换,交互式绘图等...

---
title: "test"
output: revealjs::revealjs_presentation
---

## R Markdown

This is an R Markdown presentation. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.


## Slide with Bullets

- Bullet 1
- Bullet 2
- Bullet 3

## Slide with R Code and Output

```{r}
summary(cars)
```

## Slide with Plot

```{r, echo=FALSE}
plot(cars)
```
Run Code Online (Sandbox Code Playgroud)

R Y*_*oda 11

如果手动解决方案适合您(编织时不自动生成PDF):

在浏览器中打开HTML文件并添加?print-pdf到URL,例如

http://index.html?print-pdf
Run Code Online (Sandbox Code Playgroud)

然后,您可以将幻灯片打印成PDF(例如,使用Ubuntu Linux + Firefox +"保存到文件"打印选项).


小智 5

您可以decktape用来将各种 HTML 演示文稿转换为 pdf

https://github.com/astefanutti/decktape

演示文稿中的链接将被保留,但演示文稿将不具有交互性

如果您只需要在保留交互性的同时隐藏浏览器界面,请使用全屏模式,例如在 google chrome 中按 F11