Skip to content

Flextable with image export to word by quatro not opening in word. #711

@jim-portegies

Description

@jim-portegies

In a quarto .qmd document I am trying to put images in a flextable and then export to Word. When I run the quarto process, everything seems okay, but Word refuses to open it. It says "Word experienced an error trying to open the file. Try these suggestions. * Check the file permissions... * make sure there is sufficient free memory..." but these are not the issues.

---
title: "Flextable Image Test"
format: docx
---

```{r}
library(tibble)
library(flextable)
library(dplyr)
library(here)
```

```{r}
sessionInfo()
```

```{r}
img_path <- "picture.png"
# also tried this: img_path <- normalizePath(here::here("picture.png"), mustWork = TRUE)

df <- tribble(
  ~out_path,
  img_path
)

ft <- flextable(df) |>
  colformat_image(
    j = "out_path",
    width = 2,
    height = 2
  )

ft
```

Results from sessionInfo()

locale:
[1] LC_COLLATE=English_United States.utf8
[2] LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8

time zone: Europe/Amsterdam
tzcode source: internal

attached base packages:
[1] stats graphics grDevices datasets utils methods base

other attached packages:
[1] here_1.0.2 dplyr_1.1.4 flextable_0.9.10 tibble_3.3.1

loaded via a namespace (and not attached):

[1] jsonlite_2.0.0 compiler_4.3.3 renv_1.1.6
[4] zip_2.3.3 tidyselect_1.2.1 Rcpp_1.1.1
[7] xml2_1.5.2 tidyr_1.3.2 fontquiver_0.2.1
[10] systemfonts_1.3.1 textshaping_1.0.4 uuid_1.2-1
[13] yaml_2.3.12 fastmap_1.2.0 R6_2.6.1
[16] gdtools_0.4.4 generics_0.1.4 knitr_1.51
[19] rprojroot_2.1.1 openssl_2.3.4 pillar_1.11.1
[22] rlang_1.1.7 xfun_0.56 cli_3.6.5
[25] magrittr_2.0.4 digest_0.6.39 grid_4.3.3
[28] askpass_1.2.1 lifecycle_1.0.5 vctrs_0.7.0
[31] evaluate_1.0.5 glue_1.8.0 data.table_1.18.0
[34] fontLiberation_0.1.0 officer_0.7.3 ragg_1.5.0
[37] fontBitstreamVera_0.1.1 rmarkdown_2.30 purrr_1.2.1
[40] tools_4.3.3 pkgconfig_2.0.3 htmltools_0.5.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions