0

When exporting a flextable to *.pptx using 'officer' if the flextable has a footer it seems to corrupt the power point and it needs to be repaired.

I've tried using the other footer functions. I also tried adding a header to see if that similar code throws the error. Adding headers seem fine. I also tried going back to officer v. 0.3.3.

  • Officer is v. 0.3.4
  • flextable is v. 0.5.4
  • R is 3.6.0 "Planting of a Tree"

library(officer)
library(flextable)
library(dplyr)

pdoc <- read_pptx()

footer <- "foot"
header <- "head"
myft <- iris %>% head() %>% flextable() 


myft <-   myft %>% add_header_lines( values = header) 

pdoc <- pdoc %>% 
  add_slide(layout = "Title and Content", master = "Office Theme") %>% 
  ph_with_flextable(myft , type = "body")

print(pdoc, "test1passes.pptx")

myft <-   myft %>%  add_footer_lines( values = footer) 


pdoc <- pdoc %>% 
  add_slide(layout = "Title and Content", master = "Office Theme") %>% 
  ph_with_flextable(myft , type = "body")


print(pdoc, "test2fails.pptx")

I can open the "test1passes.pptx" file with no problem. When I open the "test2fails.pptx" I get an error from pptx saying the file is corrupted when I expected that it should open with no problem.

  • 2
    Its a bug. The footer does not have height set. as a workaround, you can use functions `autofit` or `height` or `height_all`. I will fix that soon – David Gohel May 17 '19 at 10:01
  • 1
    Thanks. Changing the line to " myft <- myft %>% add_footer_lines( values = footer) %>% autofit()" worked. – Lionel Duarte May 17 '19 at 17:38

0 Answers0