Permalink
Browse files

fix pdf print bug in chrome 33 #808

  • Loading branch information...
1 parent 8b8cc60 commit 08fb6cb2f96a6d97aaa21c35a925ebb59b0b0070 @hakimel committed Feb 28, 2014
Showing with 8 additions and 2 deletions.
  1. +8 −2 index.html
View
10 index.html
@@ -20,9 +20,15 @@
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
- <!-- If the query includes 'print-pdf', use the PDF print sheet -->
+ <!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
- document.write( '<link rel="stylesheet" href="css/print/' + ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' );
+ if( window.location.search.match( /print-pdf/gi ) ) {
+ var link = document.createElement( 'link' );
+ link.rel = 'stylesheet';
+ link.type = 'text/css';
+ link.href = 'css/print/pdf.css';
+ document.getElementsByTagName( 'head' )[0].appendChild( link );
+ }
</script>
<!--[if lt IE 9]>

9 comments on commit 08fb6cb

@kittmcg

Updated index.html with the above changes, but PDF save in Chrome is still only exporting one page.

@rellen

@kittmcg If you copied directly from this view of the commit, make sure you remove any '+' characters. I didn't do this and it behaved as you describe, only one page being exported. That might be your problem.

@kirkegaard

Im having the same issue. It only prints one page and doesnt seem to include the paper css file anymore

@datadave

Same issue -- just prints single page even after fix.

@hakimel
Owner

Gonna need to see some examples of presentations where this doesn't work so I can debug. Could anyone upload theirs?

@kbremner

I was seeing a similar issue when using this fix with the Yeoman Reveal Generator. I appended bower_components/reveal.js/ to link.href and it started working as expected. Hope that helps anyone else using the Yeoman generator!

@reidma

I just installed reveal.js for the first time (using v. 2.6.2). I haven't modified anything. The first thing I did was test the print to PDF feature in Chrome. When I try to print, I can see that the "Layout" option in the Chrome print dialog appears momentarily, but then rapidly disappears. I can set the margins to zero, but can't choose "Landscape" mode printing. Thus, the slides that are printed are in landscape mode, but they are top-justified, not vertically centered, as in the posted example. Any ideas on how to fix this?

@velvia

@hakimel I can reproduce all the issues @reidma just talked about.
Chrome Version 35.0.1916.153

  • No Layout option in print dialog, slides printed top-justified, and jpgs from a few slides are missing.

To reproduce, clone http://github.com/velvia/presentations

  • Unzip reveal.js 2.6.2 distro to reveal/ subdir
  • npm install / grunt serve
  • open browser to http://localhost:8000/cassandra-spark-olap-2014/index.html?print-pdf#/
@willbuck

@kbremner having the same problem, thank you for that suggested workaround! I think I'll try to submit a PR to that generator to fix it

EDIT nevermind they already did, I just downloaded a version of the generator from NPM at a time the fix hadn't gone in yet. started work on a presentation about 3 months ago lol

Please sign in to comment.