我正在尝试使用officer向PowerPoint添加一个包含图像的灵活表对象。但是图像消失了。我可以使用 David 发布的示例来重现问题
library(flextable)
library(tibble)
download.file("https://www.r-project.org/logo/Rlogo.png", destfile = "Rlogo.png")
pupil.tbl <- tribble(
~col1, ~col2, ~col3,
"A", "B", "Rlogo.png",
"C", "D", "Rlogo.png"
)
pupil.tbl <- as.data.frame(pupil.tbl)
# display only col1 and col2
pupil.ft <- flextable(pupil.tbl, col_keys = c("col1", "col2") )
add_img_to_flextable <- function(ft, i, j){
display(
ft, i=i, col_key = j, pattern = "{{att_tbl}}",
formatters = list(# use col3 even if not displayed
att_tbl ~ as_image(col3, src = col3, width = 1.29, height = 1)
)
)
}
pupil.ft <- add_img_to_flextable(pupil.ft, i = 2, j = "col2")
如果我运行:
print(pupil.ft,preview='html')
print(pupil.ft,preview='docx')
一切正常,但在 PPTX 格式中,图像不再显示 print(pupil.ft,preview='pptx')
这是 PowerPoint 的已知限制吗?是否有任何解决方法如何在表格中显示图像?
谢谢,
菲利普