如何以编程方式将 RMarkdown ioslides 演示文稿转换为 2-up PDF? [英] How do I convert RMarkdown ioslides presentations to 2-up PDFs programmatically?

查看:54
本文介绍了如何以编程方式将 RMarkdown ioslides 演示文稿转换为 2-up PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 rmarkdown 生成 ioslides HTML 演示文稿,使用自定义 css.这一点很棒,我喜欢它.我的问题是关于生成演示文稿的注释"版本.

我见过从这些幻灯片中获得 2up PDF A4 笔记的唯一方法是从 Safari 中打印出来,点击打印...,然后横向,然后布局 2pages,然后边框 = 细线,然后另存为.然后找到正确的文件夹等.但是,它获得了正确的格式和字体,并且 Webkit 呈现了 Chrome 或其他解决方案无法呈现的内容.

这对于一个副本来说没问题.但我现在一次定期更新 9 到 30 个单独的演示文稿,所有的点击都让我发疯,尤其是当我只需要更新一个小问题时,我想检查所有文件都已重新生成为 PDF.

是否有任何解决方案可以以编程方式快速生成一组 RMarkdown ioslides 演示幻灯片的 2-up PDF 版本?或者,我们将不胜感激.

解决方案

您可以使用 webshot 包来捕获 HTML 图形的输出并将其保存到图形设备(PDF、PNG、PDF).您可以在

我不确定这是否完全符合您的确切要求,但希望足以让您朝着正确的方向前进.

<块引用>

您可以查看 pdfpages LaTeX 页面的文档以自定义 PDF 的方式幻灯片出现在文档中(添加边距、边框等)

I use rmarkdown to generate ioslides HTML presentations, using custom css. This bit is great and I love it. My question is about generating 'notes' versions of presentations.

The only way I've seen to get 2up PDF A4 notes from these slides is to print out of Safari, by clicking Print..., then landscape, then layout 2pages, then border = hairline, then save as. then find the right folder etc. However, it gets the formatting and fonts right, and Webkit renders things that Chrome or other solutions will not.

This is fine for one copy. But I am now regularly updating between 9 and 30 separate presentations at a time and all the clicking sends me nuts, especially when I need to update just a small issue, and I want to check all files have been regenerated as PDF.

Is there any solution to rapidly and programmatically generate a 2-up PDF version of a set of RMarkdown ioslides presentation slides? Alternatively good workarounds would be appreciated.

解决方案

You can use the webshot package to capture the output of HTML graphics and save this to a graphical device (PDF, PNG, PDF). You can read about it here.

Assuming you have a file called testPres.Rmd stored in the same working directory of the following script, it will convert the report to a PDF:

# Setup
install.packages("webshot")
webshot::install_phantomjs()

library(webshot)
library(rmarkdown)

rmdshot("testPres.Rmd", "document.pdf")

Having created a PDF of the slides, we now need to convert them into a two-page PDF. There is probably a more elegant way of doing this but you could use a very basic R Markdown document. This following script will load all the slides into a two-page layout:

---
output: pdf_document
header-includes:
  - \usepackage{pdfpages}
papersize: a4paper
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

\includepdf[pages={1-},scale=0.75, nup=1x2]{document.pdf}

I am not sure this meets your exact requires perfectly, but hopefully is enough to set you in the right direction.

You can check the documentation of the pdfpages LaTeX page to customise how the PDFs of the slide appear in the document (add margins, borders etc.)

这篇关于如何以编程方式将 RMarkdown ioslides 演示文稿转换为 2-up PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆