1

Situation

Hi. I'm trying to download the .pptx Rmarkdown report from shinyapps.io. The problem is, I want to download a graph with a multibyte character. (Japanese)

Since shinyapps.io does not provide Japanese font, I use the showtext package to render the graph with a multibyte character, and it works well with displaying in the browser.

However, when I try to download the .pptx file via downloadHandler() using rmarkdown::render, downloaded .pptx file come with Japanese font (and all the multibyte character within the font "collapsed".)

Reproducible example

#app.r
library(shiny)
library(tibble)
library(ggplot2)
library(magrittr)
library(showtext)

showtext.auto(TRUE)

ui <- fluidPage(
    downloadButton("dl","DL"),
    plotOutput("plot")
)

server <- function(input, output) {
    
    tempplot <- reactive({
        dat <- tibble(x = c("い","ろ","は"),
                      y = c(10,20,30))
        ggplot(dat) +
            geom_col(aes(x = x, y = y))
    })
    
    output$plot <- renderPlot({
        tempplot()
    })
    
    output$dl <- downloadHandler(
        filename = function(){"test.pptx"},
        content  = function(con){
            rmarkdown::render(input = "test.Rmd",
                              output_file = con)
        }
    )
}

shinyApp(ui = ui, server = server)


#global.R
library(shiny)
library(tibble)
library(ggplot2)
library(magrittr)
library(showtext)
#test.Rmd

---
title: "test"
output: powerpoint_presentation
---

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

## マルチバイト文字

```{r}
tempplot()
```


Result

This is what displayed in the application at shinyapps.io. Multibyte characters are displayed as intended.

enter image description here

Whereas, downloaded .pptx file is as follows.

enter image description here

Question

Is there any way I can download the .pptx file with multibyte character from shinyapps.io? (As displayed in the app in shinyapps.io.

ironwest
  • 187
  • 2
  • 9

2 Answers2

1

After some extra search, I found the solution.

This web page explains what I needed.

I just needed to add fig.showtext = TRUE to the chunk to apply the showtext package's effect to the graph within the rmarkdown.

ironwest
  • 187
  • 2
  • 9
0

what if you tried

---
title: "test"
output: powerpoint_presentation
    self_contained: yes
    mode: selfcontained
---

in your .Rmd file or maybe just

---
title: "test"
output: powerpoint_presentation
    self_contained: yes
---

This is suppose to encapsulate the entire document into a file with all the information it needs to regenerate, but I haven't used it with .pptx files

Daniel_j_iii
  • 3,041
  • 2
  • 11
  • 27
  • Thanks for the answer, Daniel. I tried your recommendation, but both do not work when I download from shinyapps.io. – ironwest Aug 09 '20 at 11:37