From d4133f0160f757af90649710769789631d4a93a0 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Tue, 24 Jan 2017 14:48:36 +0100 Subject: [PATCH] fix empty pages in pdf exports (closes #1804) --- css/print/pdf.css | 3 ++- js/reveal.js | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/css/print/pdf.css b/css/print/pdf.css index 4bfcddc..8c82f73 100644 --- a/css/print/pdf.css +++ b/css/print/pdf.css @@ -90,7 +90,7 @@ ul, ol, div, p { } .reveal .slides section { - page-break-after: always !important; + page-break-after: auto !important; visibility: visible !important; display: block !important; @@ -139,6 +139,7 @@ ul, ol, div, p { left: 0; width: 100%; height: 100%; + z-index: auto !important; } /* Display slide speaker notes when 'showNotes' is enabled */ diff --git a/js/reveal.js b/js/reveal.js index 6a31424..66ed4d0 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -598,7 +598,7 @@ // Dimensions of the PDF pages var pageWidth = Math.floor( slideSize.width * ( 1 + config.margin ) ), - pageHeight = Math.floor( slideSize.height * ( 1 + config.margin ) ); + pageHeight = Math.floor( slideSize.height * ( 1 + config.margin ) ); // Dimensions of slides within the pages var slideWidth = slideSize.width, @@ -652,7 +652,12 @@ // so that no page ever flows onto another var page = document.createElement( 'div' ); page.className = 'pdf-page'; - page.style.height = ( pageHeight * numberOfPages ) + 'px'; + + // Reduce total height by 1px so that the page ends before + // the page, otherwise the page's 'page-break-after' will + // land on the wrong page + page.style.height = ( ( pageHeight * numberOfPages ) - 1 ) + 'px'; + slide.parentNode.insertBefore( page, slide ); page.appendChild( slide );