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
173 stars 12 forks source link

Can't print local image? #35

Closed giabaio closed 3 years ago

giabaio commented 3 years ago

Hi there, I may be missing something obvious, but I seem to have a slight problem with printing to pdf. I have a relatively simple set of slides, which I can compile to html (full repo here). I have used

xaringanBuilder::build_pdf("HoD-FF.html")

but you can see how the logo on the left-bottom corner of the slides is just not printed. Interestingly, it does work when I do

xaringanBuilder::build_pdf("HoD-FF.Rmd")

I don't think building the pdf from the original Rmd or the compiled html makes any difference (I've tried both). I've also tried to print directly from Chrome, but the same thing happens. Also, I've tried to compile to a self-contained html, but it seems like the local image assets/logo.png (which is placed on the left-bottom corner, together with some text) doesn't show...

Is there anything obviously wrong that I'm just not seeing? Thanks! Gianluca

gadenbuie commented 3 years ago

My first guess is that this is a the result of a common problem when printing slides with Chrome where Chrome tends to remove images that extend past the boundary of the boundary of the printing area. You can see that this happens with the footer:

image

My recommendation is to change the .footer-left positioning rule to position the bottom edge of the element relative to the bottom of the slide (the current rules moves the top edge of the footer down to the bottom but if the height of the element is larger than 100% - top you'll run into this problem).

.footer-left {
    position: fixed;
-   top: 96.6%;
+   bottom: 0;
    left: 0;
    text-align: left;
    width: 93%;
    font-size: 70%;
    color: white;
}
jhelvy commented 3 years ago

@gadenbuie beat me to it - I think it's Chrome dropping the image.

giabaio commented 3 years ago

Thank you @gadenbuie and @jhelvy --- that's very helpful and interesting. All seems to work OK if I replace

top: 96.6%;

with

bottom: -1%;

Thanks so much! Gianluca