2016-11-24 108 views
2

我在R中做了一个演示,使用了一个reveal.js模板(使用了revealjs R包)。如何把R reveal.js演示文稿转换为PDF?

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

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

下面是示例代码,它生成“test.html”文件。我想产生“检验.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) 
``` 
+0

如果包含某种[可重现的示例](样本可能重现)(例如http://support.microsoft.com/kb/5963269/how-to-make-a-great-r-reproducible-example)可以测试的代码。 – MrFlick

+0

使用Chrome浏览器,选择打印并保存为PDF .... –

+0

@MartinSchmelzer保存为pdf将生成静态pdf文件,丢失包括交互式图表,过渡标题等演示文稿的属性。 – piyush

回答

3

如果手动解决方案是给你的OK(无自动生成的PDF文件时,你编织) :

在浏览器中打开您的HTML文件并将?print-pdf添加到URL, G。

http://index.html?print-pdf 

然后,您可以打印滑入PDF(例如与Ubuntu Linux操作系统+火狐+ “保存到文件” 打印选项)。