I want to add a graphic in the form of a pdf to a power point file created by officer. The following code works, in the sense that the powerpoint is created and the pdf is included. But to get to the powerpoint you have to let it repair itself. Here's an example
library(officer)
library(magrittr)
my_pres <- read_pptx()
testpdf <- "test.pdf"
extImgObs_pdf <- external_img(src = testpdf)
fp_3 <- fp_text(italic = TRUE, color = "black", font.size = 14)
my_pres <- add_slide(x = my_pres, layout = 'Title Only', master = 'Office Theme')
titleTextObserved <- "some text for the title field"
my_pres <- ph_with( x = my_pres, value = fpar(ftext(titleTextObserved, fp_3)), location = ph_location_type(type = "title") )
my_pres <- ph_with( x = my_pres, value = extImgObs_pdf, location = ph_location(left = 0, top = 1.2) )
print(my_pres, target = "presentations/cmip6/chillHours_Ensemble.pptx") %>% browseURL()
With some arbitrary test.pdf file (I've generated it with the pdf driver in R and removed whitespace with the linux pdfcrop
program), the above code generates a powerpoint. If you click the Repair ok message the powerpoint shows up as expected. But when you click Cancel rather than Repair, Powerpoint returns "Sorry, PowerPoint can't read ^O." Is there any way to remove the Repair message other than by manually clicking Repair
?
Clicking repair makes the pdf image visible locally but the ppt doesn't show the graphic for others. Need to use something other than pdf for the graphics. png, tiff, bmp and jpeg are options.