javascript reveal.js 打印到 pdf 只打印第一张幻灯片?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23571270/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
reveal.js print to pdf only prints the first slide?
提问by cboettig
I am trying to use the pdf export option of reveal.js as documented in the repo readme.
我正在尝试使用repo readme 中记录的reveal.js 的pdf 导出选项。
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
- 我在 chrome 打印窗口中没有看到布局选项(横向与纵向)
- 打印只打印第一张幻灯片
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.
不知道我做错了什么或如何解决它。我在这个示例文件中使用了来自 Github 的最新版本的reveal.js css 等(sha:131c00689a4c7a18e5c991fc8102347e4594b5d4)。
I'm using Google-chrome Version 34.0.1847.132 on Ubuntu 14.04
我在 Ubuntu 14.04 上使用 Google-chrome 版本 34.0.1847.132
回答by William Zhang
Remove
<link rel="stylesheet" media="print" href="reveal.js/css/print/pdf.css" />
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>
Add
?print-pdf
to the end of URL, e.g. change.../index.html#
to.../index.html?print-pdf#
消除
<link rel="stylesheet" media="print" href="reveal.js/css/print/pdf.css" />
添加
<!-- 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>
添加
?print-pdf
到 URL 的末尾,例如更改.../index.html#
为.../index.html?print-pdf#
回答by Fred K
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:
我使用幻灯片制作了一个演示文稿并将其导出为 HTML,但对我来说,William Zhanf 解决方案根本不起作用。我已经覆盖了所有的幻灯片。我是这样解决的:
- Download the
pdf.css
from hereand place it in the same folder with the html file. - Paste before the
</body>
tag the William Zhanf snippet (with changed path to the css file):
pdf.css
从这里下载并将其与 html 文件放在同一文件夹中。- 在
</body>
标签之前粘贴William Zhanf 片段(更改了 css 文件的路径):
<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>
- Then follow the same instruction: add
?print-pdf
to the end of URL and print as PDF from Chrome.
- 然后按照相同的说明:添加
?print-pdf
到 URL 的末尾并从 Chrome 打印为 PDF。