Closed Mathiaslauber closed 2 years ago
Howdy @Mathiaslauber !
I converted your question into a reprex
and wasn't able to reproduce.
Can you confirm, your gtExtras
and webshot2
pkg version?
packageVersion("gtExtras")
packageVersion("webshot2")
library(gtExtras)
library(gt)
mtcars %>%
head() %>%
gt() %>%
tab_header(
title = "Autocorrélation spatiale : I de Moran",
subtitle = "n : 2288 entreprises [EU]" ) %>%
gt_theme_nytimes() %>%
gtsave_extra("test-tab.png", selector = "table")
#> If all HTML is not captured, you can try using the 'webshot2' package directly.
knitr::include_graphics("test-tab.png", dpi = 300)
Created on 2022-05-12 by the reprex package (v2.0.1)
Howdy @Mathiaslauber - closing this for now, let me know if you aren't able to confirm the reprex as seen above.
@jthomasmock Thank you for your answer, sorry I'm answering late. Busy writing thesis. Your code actually work, but i have same problem exporting png : headers with wrong font.
I tried 2 things (version A, B): Basically exporting png before and after creating table. Note : the table font is correct in Rstudio preview. In both case after exporting, header font is arial.
Registered S3 method overwritten by 'webshot':
method from
print.webshot webshot2
If all HTML is not captured, you can try using the 'webshot2' package directly.
library("webshot2")
library("gtExtras")
library("gt")
version a
plot <- mtcars %>%
head() %>%
gt() %>%
tab_header(
title = "Autocorrélation spatialee : I de Moran",
subtitle = "n : 2288 entreprises [EU]" ) %>%
gt_theme_nytimes() %>%
gtsave_extra("E:/Dropbox/Travail master/0_data/R/extraction/13_moran_tables/Output/test-tab.png", selector = "table")
version b
plot <- mtcars %>%
head() %>%
gt() %>%
tab_header(
title = "Autocorrélation spatialee : I de Moran",
subtitle = "n : 2288 entreprises [EU]" ) %>%
gt_theme_nytimes()
path <- "13_moran_tables/Output/"
gtsave(plot, "try1.png", path = path)
gtsave_extra(plot, "try2.png", path = path)
Here version on packages as requested :
packageVersion("gtExtras") [1] ‘0.3.1’ packageVersion("webshot2") [1] ‘0.0.0.9000’
Gotcha, so when that message prints: use webshot2
directly it means to call something like:
webshot2::webshot("file.html", "output.png")
You're still using webshot::webshot()
in the calls as reported with the older version of gtExtras::gtsave_extra()
.
Now that webshot2
is on CRAN, I've updated the internals to use webshot2
for everything.
Can you try:
gtExtras
gtsave_extra()
on your table?Based off the session info I see you're on Windows, and it's possible there are some path issues (an actual bug) but my initial suspicion is that it's a limitation of the older webshot
vs webshot2
.
@jthomasmock
GtExtras
package (from 0.3.1 to 0.3.8)webshot
and upgrade webshot2
It works perfectly fine. the .png exported is exactly the same as in R preview.Woohoo!
Hello,
I have created a table :
Problem is : exported PNG has not the right Title font, but a standard one instead. I have downloaded webshot2, and I used gtsave_extra. Here are screenshot from R and 2nd one is the png file exported.
I have found, with the guardian gt theme, that the problem is not appearing.