Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert R reveal.js presentation to pdf?

I made a presentation in R, using one of the reveal.js templates (using revealjs R package).

By default, its generating a html file and when opened for presentation it displays top part of the browser including bookmarks, filepath etc... I can turn off bookmarks bar but not the filepath part, I need to present this in a formal setting so exporting the presentation to pdf seems like a better option.

Does anyone know how to export it to pdf? Can I add anything in the YAML header so that the output will be pdf and not html?

Below is the sample code, it generates "test.html" file. I want to generate "test.pdf" while preserving all other properties of presentations e.g transitions, interactive plots etc...

---
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)
```
like image 366
piyush Avatar asked Nov 24 '16 04:11

piyush


2 Answers

If a manual solution is OK for you (no automatic generation of PDFs when you knit):

Open your HTML file in the browser and add ?print-pdf to the URL, e. g.

http://index.html?print-pdf

You can then print the slides into PDF (e. g. with Ubuntu Linux + Firefox + "save to file" printing option).

like image 67
R Yoda Avatar answered Sep 30 '22 15:09

R Yoda


you may use decktape to convert various HTML presentations to pdf

https://github.com/astefanutti/decktape

The links inside the presentation will be preserved, yet the presentation will not be interactive

If you just need to hide the browser interface while preserving interactivity, use fullscreen mode e.g. in google chrome press F11

like image 43
Hatem Avatar answered Sep 30 '22 14:09

Hatem