Skip to content
a snarky powerpoint from xaringan demo
HTML CSS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
img
slides
slides_files/figure-html
README.md
slides.Rmd
slides.html
slides.pdf
slides_powerpoint.Rmd
slides_powerpoint.pptx
xaringan-themer.css

README.md

An only mildly snarky xaringan to powerpoint converter

slides_html <- "slides.html"

# "print" HTML to PDF
pagedown::chrome_print("slides.html", output = "slides.pdf")

# how many pages?
pages <- pdftools::pdf_info("slides.pdf")$pages

# set filenames
filenames <- sprintf("slides/slides_%02d.png", 1:pages)

# create slides/ and convert PDF to PNG files
dir.create("slides")
pdftools::pdf_convert("slides.pdf", filenames = filenames)

# Template for markdown containing slide images
slide_images <- glue::glue("
---

![]({filenames}){{width=100%, height=100%}}
  
")
slide_images <- paste(slide_images, collapse = "\n")

# R Markdown -> powerpoint presentation source
md <- glue::glue("
---
output: powerpoint_presentation
---

{slide_images}
")

cat(md, file = "slides_powerpoint.Rmd")

# Render Rmd to powerpoint
rmarkdown::render("slides_powerpoint.Rmd")  ## powerpoint!

Requirements

This requires xaringan (obvs), pagedown for the chrome_print() function, pdftools to handle the .pdf to .png conversion, and glue because it makes template strings in R easy. I also used xaringanthemer for the xaringan theme.

You can’t perform that action at this time.