Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docx files rendered with Quarto are broken when images are included (e.g. using as_image, or colformat_image) #612

Open
cmhh opened this issue Mar 5, 2024 · 4 comments
Labels

Comments

@cmhh
Copy link

cmhh commented Mar 5, 2024

docx files rendered with Quarto fail to open if table cells include images, for example using the as_image or colformat_image functions. For example, if we include the example provided by ?as_image in a Quarto document, the result is broken. A minimal file is:

---
format: docx
---

```{r}
library(flextable)

img.file <- file.path(
  R.home("doc"),
  "html", "logo.jpg"
)

if (require("magick")) {
  myft <- flextable(head(iris))
  myft <- compose(
    myft,
    i = 1:3, j = 1,
    value = as_paragraph(
      as_image(src = img.file),
      " ",
      as_chunk(
        Sepal.Length,
        props = fp_text_default(color = "red")
      )
    ),
    part = "body"
  )
  ft <- autofit(myft)
  ft
}
```

The typical error I get when opening the generated file is:

error
@cmhh
Copy link
Author

cmhh commented Mar 5, 2024

Interestingly, outputting to RTF works. This might prove a useful workaround in the short-term.

Edit: wait, not really--the tables in my RTF output are bitmap images.

@davidgohel
Copy link
Owner

davidgohel commented Mar 6, 2024

Yes see https://davidgohel.github.io/flextable/reference/as_image.html#note

It works with officer, officedown with r markdown but not quarto

We can't do anything about that

@cmhh
Copy link
Author

cmhh commented Mar 6, 2024

Okay, thanks. Is there something that Posit need to do on their end, or is it just a dead end? I don't know anything about the implementation, but I'd naively thought Quarto was something like a superset wrt rmarkdown.

@davidgohel
Copy link
Owner

no I don't think so, flextable output raw HTML, raw latex, raw OOXML code. Quarto manage markdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants