How to convert R reveal.js presentation to pdf?
Asked Answered
M

2

19

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)
```
Mesopause answered 24/11, 2016 at 4:58 Comment(7)
It would be easier to help if you included some sort of reproducible example with sample code that can be tested.Bracknell
Use Chrome, select Print and save as PDF ....Missionary
@MartinSchmelzer saving as pdf will just generate static pdf file losing properties of presentation including interactive plots, transitions headers etc..Mesopause
@Bracknell added reproducible example with sample codeMesopause
I am not aware of any possibility to make plots inside pdf files interactive.Missionary
Would that solution work in RStudio: github.com/hakimel/reveal.js#pdf-export ?Heaume
For Example revealjs-tlusfuctem.now.sh/mob.html?print-pdf For PDF generated and then save as PDFLyublin
A
36

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).

Aguilera answered 7/12, 2016 at 17:9 Comment(0)
W
12

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

Wentworth answered 8/12, 2019 at 12:36 Comment(4)
Sometimes the default resolution cripples the slide layout. Try to tweak the value using the -s parameter.Uncouple
Wow, this repo is amazing!Galloromance
Perfect. It saved my day.Tiller
this worked like a charm!Resolvent

© 2022 - 2024 — McMap. All rights reserved.