jhelvy / renderthis

An R package for building xaringan slides into multiple outputs, including html, pdf, png, gif, pptx, and mp4.
https://jhelvy.github.io/renderthis
Other
174 stars 12 forks source link

build_pdf tends to crop bottom of slide? #16

Open mattansb opened 3 years ago

mattansb commented 3 years ago

This seems to happen for images that are too close to the bottom of the slide. E.g.:

https://mattansb.github.io/bayesian-evidence-iscop-2021/#33

Turns into this:

image

jhelvy commented 3 years ago

Hmm, I've tried two ways to build a pdf from your slides, but both ways cut off the bottom charts:

input <- "https://mattansb.github.io/bayesian-evidence-iscop-2021/index.html"
build_pdf(input)
build_pdf(input, complex_slides = TRUE)

The first approach relies on pagedown::chrome_print(). The second uses the {chromote} package, but in the end also prints from Chrome. So I think this may just be an issue with how Chrome prints pages to pdfs.

Edit: The above code will only work with v. 0.0.5, which I just pushed. I realized I hadn't enabled some of the build functions to build directly from slides on a website, but that now should be enabled.

mattansb commented 3 years ago

So I think this may just be an issue with how Chrome prints pages to pdfs.

I'm not sure about that - attached is a print from chrome which does have the last graph: test.pdf

jhelvy commented 3 years ago

How did you print that? I just opened the slides in Chrome on my machine and printed them directly from Chrome, and I got the same crop problem. If you're able to print it without the crop there must be a solution, maybe a setting that can be tweaked.

mattansb commented 3 years ago

I did the same - opened the slide in chrome (win10) and ctrl+p as pdf...

jhelvy commented 3 years ago

Interesting...I'm on a mac, but I wouldn't expect that to be the root cause. It's particularly odd that you get a difference between using "Open Chrome -> ctrl + p" compared to pagedown::chrome_print() since those should be the same thing. I feel like there might be a different print setting in the "Open Chrome -> ctrl + p" method that is not used with pagedown::chrome_print()

mattansb commented 3 years ago

This is what I get:

image

jhelvy commented 3 years ago

Okay so it looks like it might be an issue with the margin settings.

On my machine, the default margins crop the slide:

margin_default

But if I set the margins to "minimum" and include headers and footers, it doesn't crop the charts, though is still looks like it crops a tiny amount on the bottom since the slide number is chopped a bit:

margin_minimum

I still can't find a setting on my end that looks like yours, but this is promising as I can probably change the print settings from pagedown::chrome_print().

mattansb commented 3 years ago

Awesome (: