Skip to content

Commit

Permalink
new cli and in-browser pdf printing compatible fix for hakimel#1804
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimel committed Apr 4, 2017
1 parent ec9c055 commit fa117c4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 4 additions & 3 deletions css/print/pdf.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ ul, ol, div, p {
position: relative;
overflow: hidden;
z-index: 1;

page-break-after: always;
}

.reveal .slides section {
page-break-after: always !important;

visibility: visible !important;
display: block !important;
position: relative !important;
position: absolute !important;

margin: 0 !important;
padding: 0 !important;
Expand All @@ -115,6 +115,7 @@ ul, ol, div, p {
}

.reveal section.stack {
position: relative !important;
margin: 0 !important;
padding: 0 !important;
page-break-after: avoid !important;
Expand Down
12 changes: 10 additions & 2 deletions js/reveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@
slideHeight = slideSize.height;

// Let the browser know what page size we want to print
injectStyleSheet( '@page{size:'+ pageWidth +'px '+ pageHeight +'px; margin: 0 0 -1px 0;}' );
injectStyleSheet( '@page{size:'+ pageWidth +'px '+ pageHeight +'px; margin: 0px;}' );

// Limit the size of certain elements to the dimensions of the slide
injectStyleSheet( '.reveal section>img, .reveal section>video, .reveal section>iframe{max-width: '+ slideWidth +'px; max-height:'+ slideHeight +'px}' );
Expand Down Expand Up @@ -664,7 +664,15 @@
// so that no page ever flows onto another
var page = document.createElement( 'div' );
page.className = 'pdf-page';
page.style.height = ( pageHeight * numberOfPages ) + 'px';

// Set the total height of the PDF page container.
//
// This is offset by -1 to ensure that the page ends and
// breaks within the document/paper height. Ending exactly
// on the document height breaks in-browser printing, but
// works in CLI printing (phantomjs, wkpdf etc]).
page.style.height = ( ( pageHeight - 1 ) * numberOfPages ) + 'px';

slide.parentNode.insertBefore( page, slide );
page.appendChild( slide );

Expand Down

0 comments on commit fa117c4

Please sign in to comment.