-
-
Notifications
You must be signed in to change notification settings - Fork 16.6k
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
Print to pdf doesn't center in page or print code blocks #563
Comments
Ignore the first issue. It is a problem with my own css... |
I tried but was never able to achieve vertically centered slides in PDF output. Unfortunately no change since then so this limitation will remain. |
I would try with a 'print' or 'PDF' specific CSS rule to make a box around the slide, a box inside the full page, then center. |
I got the vertical centering to work by wrapping all slide contents with 2 divs and using flexbox: function toArray(o) {
return Array.prototype.slice.call(o);
}
toArray( document.querySelectorAll( '.reveal .slides section' ) ).forEach(function(slide){
var outerWrapper = document.createElement('div');
outerWrapper.style.cssText = 'display:flex; align-items:center; height:100%';
var wrapper = document.createElement('div');
wrapper.style.width = '100%';
outerWrapper.appendChild(wrapper);
toArray( slide.children ).forEach(wrapper.appendChild, wrapper);
slide.style.height = '100%';
slide.appendChild(outerWrapper);
}); running this snippet on the dev tools just before exporting the PDF solved the issue for me (chrome 32.0.1652.0 canary). I'm not submitting a pull request because I don't know what you guys would like to do, if the whole centering logic should be changed to use flexbox in all cases or if it should be just a simple monkey-patch in case I had the "idea" thanks to solved by flexbox PS: there is also another issue asking for same feature (#458) |
Thanks @millermedeiros. Hadn't considered flexbox for this. Judging by http://caniuse.com/flexbox it seems compatible enough to merit a migration from the current JS-based centering for both normal viewing and PDF printing. Will file a new issue to give that a try. |
Great! I have just added to my reveal.js presentation and works perfectly Thanks @millermedeiros! |
When using markdown syntax this code does not work and I have not been able to solve it. I used JQuery and the sections are identified but the content is not inserted :-( @millermedeiros Could you help me? |
I am using the latest version of reveal.js (from 8/16 master) and am having a couple of problems with the print to pdf plugin.
The first is that code snippets (inside of a
The text was updated successfully, but these errors were encountered: