jgm / pandoc

Universal markup converter
https://pandoc.org
Other
33.85k stars 3.34k forks source link

Powerpoint output: images in master slides result an empty duplicate in output #4827

Open rich-iannone opened 6 years ago

rich-iannone commented 6 years ago

The full minimal reproducible example can be downloaded here: test.zip

pwrpnt.md:

---
title: "Untitled"
output:
  powerpoint_presentation:
    reference_doc: template.potx
---

# Title Slide

Title

## Second Slide

- bullet 1
- bullet 2

template.potx is within the zip file (cannot be attached here).

The following is run at command line (with pandoc 2.2.1):

pandoc +RTS -K512m -RTS pwrpnt.md --to pptx --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output pwrpnt.pptx --reference-doc template.potx

Here's a screenshot of the output .pptx (where I dragged the second image frame to the lower right):

powerpoint_image_master

The issue is the non-necessary image (which cannot find the image anyway) that appears in the same position as the image in the master slide. The user can manually delete those extra image frames though.

rich-iannone commented 6 years ago

This relates to a user issue posted in https://github.com/rstudio/rmarkdown/issues/1419, which is now closed in favor of the issue here.

guanjwcn commented 5 years ago

What is the solution for this issue? I couldn't find any solutions following the threads here. Appreciate any advice. Thanks.

millerjef commented 5 years ago

I have a work template that contains images.

When I use rstudio/rmarkdown/pandoc to output a powerpoint presentation using this template (via reference_doc in YAML header), I get the error message that powerpoint found a problem with content in... powerpoint can attempt to repair the presentation.

When I repair it, it says, "PowerPoint couldn't read some content in..." however, the slide deck still mostly renders. Weirdly, the images still render with a tiny red x and an error message saying, "The picture can't be displayed" over the top of the image. Like this:

image

and this: image

If I don't use the template, the presentation renders without any error messages.

I am using pandoc version 2.5, R 3.5.1, rmarkdown 1.11, rstudio preview 1.2.1206. This behavior occurs in both windows and macOS X environments.

burnce commented 5 years ago

Hello,

I am also seeing this, but the overlaid image placeholder says: "To help protect your privacy, Powerpoint has blocked automatic download of this picture." I also note that the overlay is on the actual slide, while the correctly displayed image is part of the slide master as expected.

Running on linux with R 3.5.2, rmarkdown 1.11 and Pandoc 2.5 (no RStudio involved).

Cheers,

Bernhard

MattCowgill commented 5 years ago

Any suggestions for a workaround to this?

guanjwcn commented 5 years ago

Probably create two same templates except that one doesn’t have background pictures. Using the one without background pictures in R and switch to the other template in PowerPoint.

Kind regards,

Junwei

On 12 Feb 2019, at 12:06 PM, Matt Cowgill notifications@github.com wrote:

Any suggestions for a workaround to this?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

awalker89 commented 5 years ago

I've found a hacky workaround by deleting the section out of my slides.xml.

For the above example, in <unzipped-pptx-dir>/ppt/slides/slide1.xml there is image

just delete it.

In R, this works for me

## generate pptx
rmarkdown::render("pwrpnt.md", output_format = "powerpoint_presentation")

## unzip it
unzip("pwrpnt.pptx", exdir = "unzipped-pptx")

### remove the <p:pic> section and write back out
doc <- xml2::read_xml("unzipped-pptx/ppt/slides/slide1.xml")
xml2::xml_remove(xml2::xml_find_all(doc, "/p:sld/p:cSld/p:spTree/p:pic"))
xml2::write_xml(doc, "unzipped-pptx/ppt/slides/slide1.xml")

## zip it back up
wd <- getwd()
setwd("unzipped-pptx")
zip::zip(zipfile = file.path(wd, "out.pptx"), files = list.files(recursive = TRUE, include.dirs = FALSE, all.files=TRUE))  
setwd(wd)

## clean up
file.copy("out.pptx", "pwrpnt.pptx", overwrite = TRUE)
unlink("out.pptx", recursive = TRUE)
unlink("unzipped-pptx", recursive = TRUE)
MattCowgill commented 5 years ago

thanks @awalker89 - that's really useful. It's annoying to have to use this workaround but I'm glad you've come up with one

lm-bsl commented 5 years ago

Hi, I was able to workaround this issue by using the background settings of the master slide (Title Slide) instead of doing a copy/paste.


Slide master with the issue > right click > format background. Fill with Picture or texture fill > select your background file

paullemmens commented 5 years ago

@lm-bsl Seems to be the correct solution from PPT perspective. Thanks for sharing. In my case, it won't work, unfortunately, because I have a master slide with a graphic and a gradient.