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

version 1.4.0 of kableExtra, save_kable() does not export the pdf as formatted in html #830

Open
irispant opened this issue Mar 20, 2024 · 2 comments

Comments

@irispant
Copy link

Description
The output of the function save_kable() of package versions 1.3.4 and 1.4.0, differs.

More specifically, the function save_kable() of package version 1.3.4 works as expected. It extracts the HTML (refer to the left image) and PDF (refer to the right image) in the correct format.
export_1 3 4

However, the same function of the package version 1.4.0, does not work as expected. After installing the recommended package webshot2 with its dependencies, the function extracts the HTML (refer to the left image) in the correct format, but the PDF (refer to the right image) is not extracted as expected.
export_1 4 0


In addition, it was noted that the exported info messages of the function save_kable(), differ between the two versions:
kableExtra version: 1.3.4
save_kable_1 3 4

kableExtra version: 1.4.0
save_kable_1 4 0


To Reproduce

Please try to reproduce the below code, using versions 1.3.4 and 1.4.0 of the package kableExtra, and inspect the pdf outputs.

iris_df <- iris[(48:52), ] 

rownames(iris_df) <- NULL

pdf_df <- knitr::kable(iris_df, caption = "Iris Dataset", align = "ccccr") |> 
  kableExtra::kable_paper() |> 
  kableExtra::column_spec(5, bold = TRUE, border_right = TRUE, background ="#F2EFC8") |> 
  kableExtra::kable_styling(bootstrap_options = "basic", full_width = FALSE, position = "center", font_size = 20) |> 
  kableExtra::kable_classic(full_width = FALSE, html_font = "Cambria") |> 
  kableExtra::pack_rows(group_label = "setosa species", start_row = 1, end_row = 3, underline = TRUE) |> 
  kableExtra::pack_rows(group_label = "versicolor species", start_row = 4, end_row = 5, underline = TRUE) |> 
  kableExtra::footnote(general = "The end") 

kableExtra::save_kable(pdf_df, "iris_df.pdf")

@haozhu233
Copy link
Owner

1.4 is using webshot2 while 1.3.4 is using webshot. f4b8f24

Technically webshot or phantom.js is deprecated but I find it sometimes works better than other tools. Maybe we should let user select the backend instead of set it for them.

@Jordanadriscoll
Copy link

Just thought I would join in with my experience in the case that it may prove helpful.

I had a recent issue that appears somewhat related to @irispant's issue with version 1.4.0. I did a mass, multiple package update for my local instance of R on my windows machine and suddenly my save_kable sections were erroring and causing my script to halt. I started playing musical chairs with the packages to try to determine which package update caused this upset. I originally thought the issue was related to the ‘magick’ package and I would receive blank output png files when I didn’t have magick installed (similar to @irispant's post of their output version comparison). I would get my png files with blank output and received this message (I have obfuscated my work username in the filepaths):

image

After re-installing magick, the png files wouldn’t write any longer and I would receive this message:
image

So the image would get written to .html file, but it seems then that there would be an issue locating the file to create the respective png file. I did revert back to the previous version of magick I had before my multiple package update but didn't luck out. However, when I regressed back to version 1.3.4 of kableExtra, my script started behaving as expected. Perhaps the update to version 1.4.0 doesn’t play nice with magick and/or webshot2 now?

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

No branches or pull requests

3 participants