flextable icon indicating copy to clipboard operation
flextable copied to clipboard

Feature Request: Save as vector image format?

Open N-Accumbens opened this issue 2 years ago • 1 comments

Hello,

Great package, I'm just wondering if it'd be possible to save tables in a vector image format like svg? Having vector format images is great if you want to zoom-in to especially large tables.

N-Accumbens avatar Aug 07 '22 13:08 N-Accumbens

Hello

Not exactly possible right now with a single command. There is one workaround via save_as_image:

library(flextable)
library(webshot2)

ft <- flextable(head(iris)) |> autofit()
save_as_image(x = ft, path = "ft.pdf", webshot = "webshot2")

The result is a vector image PDF.

davidgohel avatar Aug 07 '22 14:08 davidgohel

It's now implemented thanks to grid graphics! (note it can be slow with large tables)

library(flextable)

ft <- flextable(iris) |> autofit()
gr <- gen_grob(ft, scaling = "fixed", fit = "fixed", just = "center")
dims <- dim(gr)
svglite::svglite(filename = "hello-grid-graphics.svg", width = dims$width + .1, height = dims$height + .1)
plot(gr)
dev.off()
Capture d’écran 2022-09-06 à 17 41 43

davidgohel avatar Sep 06 '22 15:09 davidgohel

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

github-actions[bot] avatar Mar 16 '23 05:03 github-actions[bot]