I use RStudio with Quarto to create an word-document.
The YAML-Line for that is simply format: docx
That works with out any problems.
But for reasons I dont quite understand, when creating a flextable with an image the word document cant be opend after rendering. So I changed the YAML to output: officedown::rdocx_document
Now the flextable is created with the image but the document is not an .docx anymore, but an .html.
Does anyone no why or has an solution for this?
I although tried following code, the result is still a .html file
---
date: "`r Sys.Date()`"
author: "Your Name"
title: "Untitled"
output:
officedown::rdocx_document
---
{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, fig.cap = TRUE)
library(officedown)
{r}
library(flextable)
library(officer)
img.file <- file.path( R.home("doc"), "html", "logo.jpg" )
myft <- flextable( head(iris))
myft <- compose( myft, i = 1:3, j = 1,
value = as_paragraph(
as_image(src = img.file, width = .20, height = .15),
" blah blah ",
as_chunk(Sepal.Length, props = fp_text(color = "red"))
),
part = "body")
autofit(myft)
Thank you!