fix issue with deck-wide backgroudns in pdf exports + fix #2865

edit
hakimel 2021-11-16 14:10:29 +01:00
parent cc582c6ed5
commit c79f4b5a4f
3 changed files with 22 additions and 6 deletions

2
dist/reveal.esm.js vendored

File diff suppressed because one or more lines are too long

2
dist/reveal.js vendored

File diff suppressed because one or more lines are too long

View File

@ -46,14 +46,19 @@ export default class Print {
document.body.style.width = pageWidth + 'px'; document.body.style.width = pageWidth + 'px';
document.body.style.height = pageHeight + 'px'; document.body.style.height = pageHeight + 'px';
const viewportElement = document.querySelector( '.reveal-viewport' );
let presentationBackground;
if( viewportElement ) {
const viewportStyles = window.getComputedStyle( viewportElement );
if( viewportStyles && viewportStyles.background ) {
presentationBackground = viewportStyles.background;
}
}
// Make sure stretch elements fit on slide // Make sure stretch elements fit on slide
await new Promise( requestAnimationFrame ); await new Promise( requestAnimationFrame );
this.Reveal.layoutSlideContents( slideWidth, slideHeight ); this.Reveal.layoutSlideContents( slideWidth, slideHeight );
// Re-run the slide layout so that r-fit-text is applied based on
// the printed slide size
slides.forEach( slide => this.Reveal.slideContent.layout( slide ) );
// Batch scrollHeight access to prevent layout thrashing // Batch scrollHeight access to prevent layout thrashing
await new Promise( requestAnimationFrame ); await new Promise( requestAnimationFrame );
@ -90,6 +95,13 @@ export default class Print {
page.className = 'pdf-page'; page.className = 'pdf-page';
page.style.height = ( ( pageHeight + config.pdfPageHeightOffset ) * numberOfPages ) + 'px'; page.style.height = ( ( pageHeight + config.pdfPageHeightOffset ) * numberOfPages ) + 'px';
// Copy the presentation-wide background to each individual
// page when printing
if( presentationBackground ) {
page.style.background = presentationBackground;
}
page.appendChild( slide ); page.appendChild( slide );
// Position the slide inside of the page // Position the slide inside of the page
@ -97,6 +109,10 @@ export default class Print {
slide.style.top = top + 'px'; slide.style.top = top + 'px';
slide.style.width = slideWidth + 'px'; slide.style.width = slideWidth + 'px';
// Re-run the slide layout so that r-fit-text is applied based on
// the printed slide size
this.Reveal.slideContent.layout( slide )
if( slide.slideBackgroundElement ) { if( slide.slideBackgroundElement ) {
page.insertBefore( slide.slideBackgroundElement, slide ); page.insertBefore( slide.slideBackgroundElement, slide );
} }