davidgohel / officer

:cop: officer: office documents from R
https://ardata-fr.github.io/officeverse/
Other
602 stars 107 forks source link

Blank pptx in PowerPoint, fine in Libre Impress #287

Closed mikldk closed 4 years ago

mikldk commented 4 years ago

I make a pptx file from a png image:

library(officer)

full_slide <- function(x, ...){
  ph_with(x = x, ..., location = ph_location_fullsize())
}

pttx_pdf <- read_pptx() %>% 
  add_slide(layout = "Blank", master = "Office Theme")
  full_slide(value = external_img(src = "image.png"))

pttx_pdf %>% print(target = "slides.pptx")

When I open slides.pptx in LibreOffice Impress I can see the image. When I open it in MS PowerPoint the slide is blank.

See the attached image.png file and slides.pptx file.

The media is included in the pptx archive (in ppt/media/). I am doing something wrong or is there maybe a bug somewhere in the xml files?

tvedebrink commented 4 years ago

:+1:

davidgohel commented 4 years ago

When you file a bug report, please spend some time making it easy for me to follow and reproduce. The more time you spend on making the bug report coherent, the more time I can dedicate to investigate the bug as opposed to the bug report.

Your code does not run. I fixed it of course because I don't want a bug to persist if it is really a bug but it requires more times. That's why we are writing guidelines - they can be read when you open a new issue. It's particularly important to:

Really sorry for that, I know people don't always get the point but believe me, that's really painful for maintainers. Now I need to go back to work so instead of helping you, I just read your example, saw it was not running and wrote that piece of ranting. No more time left for helping this afternoon. Will come back to you later about your issue. I think it should work and yes, after having fixed your code, the image can not be seen.

library(officer)
library(magrittr)

pttx_pdf <- read_pptx() %>% 
  add_slide(layout = "Blank", master = "Office Theme") %>% 
  ph_with(external_img(src = "image.png"), location = ph_location_fullsize())

pttx_pdf %>% print(target = "slides.pptx") 
mikldk commented 4 years ago

Thanks for the rant - I deserve it not being sufficiently cautious. Thanks again.

davidgohel commented 4 years ago

Thanks, it was not obvious to find out what was wrong.

Issue is only happening when using ph_location_fullsize with a blank layout (when using "Title and Content", no problem). You were right, it was a bug in the XML. I added the necessary missing tags and now it's ok.

You can install the github version to get the fix.

mikldk commented 4 years ago

Thanks for the fast response and solution!

tvedebrink commented 4 years ago

Excellent! It works perfectly now :-)

davidgohel commented 4 years ago

Thank you both for the feedback

github-actions[bot] commented 2 years ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.