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

Printing to pdf #65

Closed
cboettig opened this issue Aug 7, 2017 · 7 comments
Closed

Printing to pdf #65

cboettig opened this issue Aug 7, 2017 · 7 comments

Comments

@cboettig
Copy link

cboettig commented Aug 7, 2017

As you probably know, many of us end up printing html5 slides into pdf in case some conference can't handle html. The remark.js Readme links an issue with some pretty good suggestions for this, gnab/remark#50 (comment) in particular, but I thought R users might like to have this included in your default css so that printing works out of the box?

The example shown there works pretty-much as is, but users might want the option to customize the aspect ratio in the markdown yaml, like one can do in @gaborcsardi's rmdshower. Maybe this is something you'd consider adding, and/or mentioning in the readme?

@ekstroem
Copy link
Collaborator

ekstroem commented Aug 7, 2017

I'd like to second that suggestion. And I'd be happy to make a PR for it if Yihui says go ahead.

@yihui
Copy link
Owner

yihui commented Aug 7, 2017

@ekstroem Please go ahead! 👍

@yihui yihui closed this as completed in 01b0b2f Aug 8, 2017
@yihui
Copy link
Owner

yihui commented Aug 8, 2017

Since this is easy to do, I have added some of these CSS rules to the default CSS. It seems @page is not necessary to me. It will be great if you guys can test the latest version here. The PDF looks good in my eyes now (previously there were ugly right/bottom margins).

@cboettig
Copy link
Author

cboettig commented Aug 8, 2017

thanks, agree it's nice to just bake this into default. will definitely test drive it. Yeah, I'm not sure why it has the @page call either, but thought perhaps it impacts the way things like background images are scaled?

@yihui
Copy link
Owner

yihui commented Aug 8, 2017

Probably. If it turns out that @page is needed, I can add it. The tricky thing is that it depends on the aspect ratio (i.e. it is dynamic).

@ekstroem
Copy link
Collaborator

ekstroem commented Aug 8, 2017

I think it has an impact if you run 16:9 ratio. Then the prints look different and setting the @page will fix that. I tinkered with adding this in default.html

<script language="javascript">
document.getElementById("@page").setAttribute(
   "style", "size: "+referenceWidth+"px "+referenceHeight+"px");
</script>

However that keeps the 4:3 ratio and not the ratio defined by the user in the yaml. I tried to figure out how to extract the actual width instead of the referenceWidth from javascript but haven't found a solution. I think the solution is somewhere in scalar.js from remark.js but I'm picking up JS as I go along.

@yihui
Copy link
Owner

yihui commented Aug 9, 2017

I have solved the @page size issue using JavaScript in 3e4eee0. Any aspect ratio will work (not limited to 16:9 and 4:3). Happy printing!

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