reveal.js print to pdf only prints the first slide?
Asked Answered
T

2

17

I am trying to use the pdf export option of reveal.js as documented in the repo readme.

I have the following problems:

  • I don't see an option for layout (landscape vs portrait) in my chrome print window
  • Printing only ever prints the first slide

No idea what I've done wrong or how to troubleshoot it. I'm using the latest version of reveal.js css etc from Github (sha: 131c00689a4c7a18e5c991fc8102347e4594b5d4) on this example file.

I'm using Google-chrome Version 34.0.1847.132 on Ubuntu 14.04

Transmutation answered 9/5, 2014 at 18:5 Comment(0)
H
31
  1. Remove

    <link rel="stylesheet" media="print" href="reveal.js/css/print/pdf.css" />
    
  2. Add

    <!-- If the query includes 'print-pdf', include the PDF print sheet -->
    <script>
      if( window.location.search.match( /print-pdf/gi ) ) {
        var link = document.createElement( 'link' );
        link.rel = 'stylesheet';
        link.type = 'text/css';
        link.href = 'reveal.js/css/print/pdf.css';
        document.getElementsByTagName( 'head' )[0].appendChild( link );
      }
    </script>
    
  3. Add ?print-pdf to the end of URL, e.g. change .../index.html# to .../index.html?print-pdf#

Heterocyclic answered 14/5, 2014 at 1:4 Comment(4)
The link to the css has to be corrected imho. Currently this seems wrong, just use css/print/pdf.cssOtherdirected
I'm getting a "Removed script tag found in deck" error message when I add this to the HTML via the web UI.Latish
In one line: document.querySelector("[media=print]").removeAttribute("media") ;)Dilettante
Plus one for the ?print-pdf! I've been trying to figure this out for ages and couldn't seem to find it on the reveal website (not saying it's not there, only that I could not find it by searching for "print").Stagg
S
8

I made a presentation using Slides and exported it in HTML, but for me the William Zhanf solution doesn't work at all. I had all the slides overlayed. This is how I solved:

  1. Download the pdf.css from here and place it in the same folder with the html file.
  2. Paste before the </body> tag the William Zhanf snippet (with changed path to the css file):
<script>
  if( window.location.search.match( /print-pdf/gi ) ) {
    var link = document.createElement( 'link' );
    link.rel = 'stylesheet';
    link.type = 'text/css';
    link.href = 'pdf.css'; // Notice: I changed the path
    document.getElementsByTagName( 'head' )[0].appendChild( link );
  }
</script>
  1. Then follow the same instruction: add ?print-pdf to the end of URL and print as PDF from Chrome.
Sheela answered 2/7, 2015 at 17:27 Comment(1)
I've got exacly the same problem with slides overlay. Your solution works like a charm! :)Sloe

© 2022 - 2024 — McMap. All rights reserved.