abide by configured width/height when printing to pdf
This commit is contained in:
parent
a522312999
commit
ddfb0aa86f
@ -30,11 +30,6 @@ html {
|
|||||||
overflow: visible;
|
overflow: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
@page {
|
|
||||||
size: letter landscape;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* SECTION 2: Remove any elements not needed in print.
|
/* SECTION 2: Remove any elements not needed in print.
|
||||||
This would include navigation, ads, sidebars, etc. */
|
This would include navigation, ads, sidebars, etc. */
|
||||||
.nestedarrow,
|
.nestedarrow,
|
||||||
|
27
js/reveal.js
27
js/reveal.js
@ -413,21 +413,19 @@ var Reveal = (function(){
|
|||||||
*/
|
*/
|
||||||
function setupPDF() {
|
function setupPDF() {
|
||||||
|
|
||||||
// The aspect ratio of pages when saving to PDF in Chrome,
|
|
||||||
// we need to abide by this ratio when determining the pixel
|
|
||||||
// size of our pages
|
|
||||||
var pageAspectRatio = 1.295;
|
|
||||||
|
|
||||||
var slideSize = getComputedSlideSize( window.innerWidth, window.innerHeight );
|
var slideSize = getComputedSlideSize( window.innerWidth, window.innerHeight );
|
||||||
|
|
||||||
// Dimensions of the PDF pages
|
// Dimensions of the PDF pages
|
||||||
var pageWidth = Math.round( slideSize.width * ( 1 + config.margin ) ),
|
var pageWidth = Math.round( slideSize.width * ( 1 + config.margin ) ),
|
||||||
pageHeight = Math.round( pageWidth / pageAspectRatio );
|
pageHeight = Math.round( slideSize.height * ( 1 + config.margin ) );
|
||||||
|
|
||||||
// Dimensions of slides within the pages
|
// Dimensions of slides within the pages
|
||||||
var slideWidth = slideSize.width,
|
var slideWidth = slideSize.width,
|
||||||
slideHeight = slideSize.height;
|
slideHeight = slideSize.height;
|
||||||
|
|
||||||
|
// Let the browser know what page size we want to print
|
||||||
|
injectStyleSheet( '@page{size:'+ pageWidth +'px '+ pageHeight +'px; margin: 0;}' );
|
||||||
|
|
||||||
document.body.classList.add( 'print-pdf' );
|
document.body.classList.add( 'print-pdf' );
|
||||||
document.body.style.width = pageWidth + 'px';
|
document.body.style.width = pageWidth + 'px';
|
||||||
document.body.style.height = pageHeight + 'px';
|
document.body.style.height = pageHeight + 'px';
|
||||||
@ -944,6 +942,23 @@ var Reveal = (function(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Injects the given CSS styles into the DOM.
|
||||||
|
*/
|
||||||
|
function injectStyleSheet( value ) {
|
||||||
|
|
||||||
|
var tag = document.createElement( 'style' );
|
||||||
|
tag.type = 'text/css';
|
||||||
|
if( tag.styleSheet ) {
|
||||||
|
tag.styleSheet.cssText = value;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tag.appendChild( document.createTextNode( value ) );
|
||||||
|
}
|
||||||
|
document.getElementsByTagName( 'head' )[0].appendChild( tag );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the height of the given element by looking
|
* Retrieves the height of the given element by looking
|
||||||
* at the position and height of its immediate children.
|
* at the position and height of its immediate children.
|
||||||
|
Loading…
Reference in New Issue
Block a user