gadenbuie / xaringanExtra

:ferris_wheel: A playground of enhancements and extensions for xaringan slides.
https://pkg.garrickadenbuie.com/xaringanExtra
Other
448 stars 36 forks source link

use_scribble() changing font-size when printing xaringan to pdf in Chrome? #136

Closed yyzeng closed 2 years ago

yyzeng commented 2 years ago

@gadenbuie Hi Garrick, Thanks for all your great work! I love scribble, tile-view, freezeframe, etc. 👍

I use Google Chrome to print xaringan slides into pdf manually (https://github.com/yihui/xaringan/wiki/Export-Slides-to-PDF#manual-conversion-via-web-browser). It just works until I have added xaringanExtra::use_scribble() in my slides recently. I found that the printed fonts shrinked about 10%, leaving some extra blanks in the bottom. I just can't figure out why. 😭

gadenbuie commented 2 years ago

@yyzeng my one guess is that maybe the scribble controls are interfering in some way. I just pushed #139 to hide the scribble controls when printing. For some reason I can't get Chrome to work for me locally, can you please try the solution that PR and let me know if it works for you?

# install the latest version of xaringanExtra
remotes::install_github("gadenbuie/xaringanExtra")

# then re-render your slides and print them
gadenbuie commented 2 years ago

@yyzeng I merged the changes in #139, so now you can just install the latest version of xaringanExtra

yyzeng commented 2 years ago

Thank you for your prompt reply.

I have updated xaringanExtra to 0.5.5, tried the following reprex example and found it does't work regretedly.

---
title: 'Test'
output:
  xaringan::moon_reader
---

```{r setup, echo=FALSE}
xaringanExtra::use_scribble()
# full-paged, but shrank to ~80% when print to a pdf via Google Chrome
print(head(mtcars, n = 29))


![Test](https://user-images.githubusercontent.com/5230361/133708892-616fcfe4-3860-4722-9a60-e6ee90ebad25.png)
gadenbuie commented 2 years ago

That's unfortunate. I tried to reproduce your problem but I'm not seeing the same issue: below is an animation with two slides derived from your example, where including or removing scribble doesn't affect the font size at all.

I'm not sure I can be much help with this issue other than suggesting two things to consider:

  1. You might need to poke around in the print settings to make sure that scaling is turned off
  2. You may want to check out xaringanBuilder which provides a fully automated build_pdf() function that may provide more consistent results.

issue-136

yyzeng commented 2 years ago

Thank you! I will clarify myself a little more, just for memo. 😄

  1. I haven't set the scaling in Google Chrome, as you can see that the slide's pagesize is right. (https://user-images.githubusercontent.com/5230361/133708892-616fcfe4-3860-4722-9a60-e6ee90ebad25.png)
  2. If I comment out xaringanExtra::use_scribble(), then everything is find.
  3. Your adviced xaringanBuilder::build_pdf() works for me, though it is a little crumsy.
    The underlied chromote::find_chrome() just CAN'T find chrome.exe's path in my computer, but I have checked and found the path is in the Register with key "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.exe\\", 😭 So, I have to set Sys.setenv("CHROMOTE_CHROME" = "C:\\Users\\admin\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe") before using xaringanBuilder::build_pdf("Test.Rmd"), then everything is ok.

Thank you once again for all your prompt reply and sound advice! 👍 @gadenbuie

gadenbuie commented 2 years ago

Glad that you got it sorted out @yyzeng. I agree, we could give better advice in xaringanBuilder, so I added a note to update the error message that you should have received from build_pdf(). Note that you can set this env var in your ~/.Renviron file (use usethis::edit_r_renviron() to open it) so that you don't have to keep setting the env variable each time you want to make PDFs.

jhelvy commented 2 years ago

We do have instructions here on the main xaringanBuilder README, but it would probably be more helpful if a careful error message was also added as this is pretty far down in the README. I should also probably just move these instructions further up in the README so that it's all up front.