Skip to content

Commit

Permalink
support for 'separate-page' layout for notes in PDF exports hakimel#1518
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimel authored and benabraham committed Nov 12, 2016
1 parent 25fcc90 commit c1aa524
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ This will only display in the notes window.

Notes are only visible to the speaker inside of the speaker view. If you wish to share your notes with others you can initialize reveal.js with the `showNotes` config value set to `true`. Notes will appear along the bottom of the presentations.

When `showNotes` is enabled notes are also included when you [export to PDF](https://github.com/hakimel/reveal.js#pdf-export).
When `showNotes` is enabled notes are also included when you [export to PDF](https://github.com/hakimel/reveal.js#pdf-export). By default, notes are printed in a semi-transparent box on top of slide. If you'd rather print them on a separate page after the slide, set `showNotes: "separate-page"`.

## Server Side Speaker Notes

Expand Down
13 changes: 12 additions & 1 deletion css/print/pdf.css
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,22 @@ ul, ol, div, p {
display: block;
width: 100%;
max-height: none;
left: auto;
top: auto;
right: auto;
bottom: auto;
left: auto;
z-index: 100;
}

/* Layout option which makes notes appear on a separate page */
.reveal .speaker-notes-pdf[data-layout="separate-page"] {
position: relative;
color: inherit;
background-color: transparent;
padding: 20px;
page-break-after: always;
}

/* Display slide numbers when 'slideNumber' is enabled */
.reveal .slide-number-pdf {
display: block;
Expand Down
21 changes: 17 additions & 4 deletions js/reveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,18 +617,31 @@

// Inject notes if `showNotes` is enabled
if( config.showNotes ) {

// Are there notes for this slide?
var notes = getSlideNotes( slide );
if( notes ) {

var notesSpacing = 8;
var notesLayout = typeof config.showNotes === 'string' ? config.showNotes : 'inline';
var notesElement = document.createElement( 'div' );
notesElement.classList.add( 'speaker-notes' );
notesElement.classList.add( 'speaker-notes-pdf' );
notesElement.setAttribute( 'data-layout', notesLayout );
notesElement.innerHTML = notes;
notesElement.style.left = ( notesSpacing - left ) + 'px';
notesElement.style.bottom = ( notesSpacing - top ) + 'px';
notesElement.style.width = ( pageWidth - notesSpacing*2 ) + 'px';
slide.appendChild( notesElement );

if( notesLayout === 'separate-page' ) {
page.parentNode.insertBefore( notesElement, page.nextSibling );
}
else {
notesElement.style.left = ( notesSpacing - left ) + 'px';
notesElement.style.bottom = ( notesSpacing - top ) + 'px';
notesElement.style.width = ( pageWidth - notesSpacing*2 ) + 'px';
slide.appendChild( notesElement );
}

}

}

// Inject slide numbers if `slideNumbers` are enabled
Expand Down

0 comments on commit c1aa524

Please sign in to comment.