Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpptx_document produces an unopenable pptx file #28

Closed
CLRafaelR opened this issue Jun 21, 2020 · 6 comments
Closed

rpptx_document produces an unopenable pptx file #28

CLRafaelR opened this issue Jun 21, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@CLRafaelR
Copy link

CLRafaelR commented Jun 21, 2020

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

MWE

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

Session Info

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
@davidgohel
Copy link
Owner

Thanks for reporting that.

It seems it only happens with R for Windows. I don't know yet where is the issue.

@davidgohel davidgohel added the bug Something isn't working label Jun 21, 2020
@mtkerbeR
Copy link

mtkerbeR commented Jun 21, 2020

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.

@CLRafaelR
Copy link
Author

CLRafaelR commented Jun 22, 2020

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

@CLRafaelR
Copy link
Author

CLRafaelR commented Jun 22, 2020

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

@davidgohel
Copy link
Owner

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

@CLRafaelR
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants