1

I'm trying to write a sequence of bullet points onto the same slide, with the following R-Code:

library(officer)
library(magrittr)

ppt <- read_pptx()

ppt <- ppt %>%
    add_slide(layout = "Title and Content", master = "Office Theme") %>%
    ph_with_text(type = "title", str = "FFT power spectrum") %>%
    ph_with_text(type = "body", str = "no visual discrimination") %>%
    ph_add_par(level = 1L) %>%
    ph_add_text(str = "whole trajectories")


print(ppt, target = "test.pptx") %>% invisible()

... which fails, saying ...

Error in doc_parse_raw(x, encoding = encoding, base_url = base_url, as_html = as_html,  : 
  Premature end of data in tag p line 1 [77]

When I change the level-parameter to

ph_add_par(level = 2L)

it works just fine (as demonstrated in the vignette: https://cran.r-project.org/web/packages/officer/vignettes/powerpoint.html)

What am I missing here?

rcst
  • 175
  • 9

1 Answers1

1

That was a bug, thanks for reporting that. You can get the dev version with devtools::install_github("davidgohel/officer").

And below a slightly modified script:

library(officer)
library(magrittr)

default_font <- fp_text(font.family = "Calibri", font.size = 0)

ppt <- read_pptx()

ppt <- ppt %>%
  add_slide(layout = "Title and Content", master = "Office Theme") %>%
  ph_with_text(type = "title", str = "FFT power spectrum") %>%
  ph_with_text(type = "body", str = "no visual discrimination") %>%
  ph_add_par(level = 1L, type = "body") %>%
  ph_add_text(str = "whole trajectories", type = "body", style = default_font )


print(ppt, target = "test.pptx") %>% browseURL()
David Gohel
  • 9,180
  • 2
  • 16
  • 34