@davidgohel
When I knit an Rmd file with officedown::rpptx_document
, the function produces an unopenable pptx file with the following error message:
PowerPoint found a problem with content in xxxx.pptx.
PowerPoint can attempt to repair the presentation.
I confirmed that the contents of the Rmd are knittable with, for eaxample, bookdown::powerpoint_presentation2
. Therefore, I suspect some bugs might lie in officedown::rpptx_document
.
---
title: "Untitled"
author: "CLRR"
date: "2020/6/20"
output:
officedown::rpptx_document:
keep_md: TRUE
bookdown::powerpoint_presentation2:
keep_md: TRUE
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## 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 Output
```{r cars, echo = TRUE}
summary(cars)
```
## Slide with Plot
```{r pressure}
plot(pressure)
```
rmarkdown::pandoc_version()
[1] ‘2.9.2.1’
R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale:
[1] LC_COLLATE=Japanese_Japan.932 LC_CTYPE=Japanese_Japan.932 LC_MONETARY=Japanese_Japan.932 LC_NUMERIC=C LC_TIME=Japanese_Japan. 932
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
Rcpp_1.0.4.6
packrat_0.5.0
digest_0.6.25
R6_2.4.1
magrittr_1.5
officedown_0.1.0
evaluate_0.14
zip_2.0.4
gdtools_0.2.2
rlang_0.4.6
uuid_0.1-4
xml2_1.3.2
rmarkdown_2.2
tools_4.0.0
officer_0.3.11
xfun_0.14
yaml_2.2.1
compiler_4.0.0
systemfonts_0.2.3 r
vg_0.2.4
memoise_1.1.0
htmltools_0.4.0
knitr_1.28
Thanks for reporting that.
It seems it only happens with R for Windows. I don't know yet where is the issue.
First of all:
Thanks for the awesome package - really great! A pleasure to work with/use it - especially in connection with flextable.
From my point of view, the problem on windows might be caused by the value of reference_doc.
While using the pptx-template in officer does not seem to work on windows (see below), the code works using the pandoc reference template:
---
title: "Untitled"
author: "CLRR"
date: "2020/6/20"
output:
officedown::rpptx_document:
# not working:
# reference_doc: C:/R/lib/officer/template/template.pptx
# set reference_doc to standard pandoc layout:
# system2(rmarkdown::pandoc_exec(), args = c("--print-default-data-file", "reference.pptx"), stdout = "C:/R/pandoc_layout.pptx")
reference_doc: C:/R/pandoc_layout.pptx
keep_md: TRUE
---
## R Markdown
Test
The choice of the template - using the officer-internal template instead of pandocs reference doc - might be triggered within the function officedown:::get_default_pandoc_data_file
see Enable usage of Pandoc-pptx-reference doc.
@mtkerbeR
The following command on R console which you suggested doesn't work:
> system2(rmarkdown::pandoc_exec(), args = c("--print-default-data-file", "reference.pptx"), stdout = "C:/R/pandoc_layout.pptx")
pandoc.exe: <stdout>: hPutBuf: invalid argument (Bad file descriptor)
Where should pandoc_layout.pptx exit innately? Or should I create a pptx file by myself instead? I don't have R
directory under my C
directory, i.e. there is no C:/R/
. I have C:\Program Files\R
, C:\Program Files\RStudio
, C:\Users\my-user-name\AppData\Local\RStudio
, C:\Users\my-user-name\AppData\Local\RStudio
.
@davidgohel and @mtkerbeR
Now I succeeded to get a pptx file!
(1) I created pandoc_layout.pptx in a certain directory (C:/Users/my-user-name/Documents/R
at this time) and
(2) ran the following code as @mtkerbeR suggested:
system2(rmarkdown::pandoc_exec(), args = c("--print-default-data-file", "reference.pptx"), stdout = "C:/Users/my-user-name/Documents/R/pandoc_layout.pptx")
(3) then I knitted a Rmd file with the option reference_doc: C:/Users/my-user-name/Documents/R/pandoc_layout.pptx
in YAML.
Thanks
This is now fixed in the github version.
There were two issues, one with the windows missing .exe
and another one about temporary file used as reference_doc
. Thanks to @mtkerbeR for the help
I confirmed the github version's officedown::rpptx_document
produces an openable file. This is brilliant!! I appreciate @davidgohel for the bug fix and @mtkerbeR for helpfull contributions!