【问题标题】:R officer powerpoint complains with external image that is a pdfR官员PowerPoint抱怨外部图像是pdf
【发布时间】:2020-05-28 06:19:06
【问题描述】:

我想将 pdf 格式的图形添加到官员创建的 power point 文件中。从创建 powerpoint 并包含 pdf 的意义上说,以下代码有效。但是要到达PowerPoint,您必须让它自行修复。这是一个例子

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()

使用一些任意的 test.pdf 文件(我使用 R 中的 pdf 驱动程序生成它,并使用 linux pdfcrop 程序删除了空格),上面的代码生成了一个 powerpoint。如果单击“修复确定”消息,PowerPoint 将按预期显示。但是,当您单击“取消”而不是“修复”时,Powerpoint 会返回“抱歉,PowerPoint 无法读取 ^O”。除了手动点击Repair之外,还有什么方法可以删除修复消息?

【问题讨论】:

    标签: r pdf officer


    【解决方案1】:

    点击修复使pdf图像在本地可见,但ppt不为其他人显示图形。需要为图形使用 pdf 以外的其他内容。 png、tiff、bmp 和 jpeg 是选项。

    【讨论】:

      猜你喜欢
      • 2021-08-28
      • 1970-01-01
      • 2010-12-25
      • 1970-01-01
      • 1970-01-01
      • 2012-08-13
      • 1970-01-01
      • 2012-03-03
      • 2022-07-05
      相关资源
      最近更新 更多