【问题标题】:reveal.js print to pdf only prints the first slide?reveal.js print to pdf 只打印第一张幻灯片?
【发布时间】:2014-06-27 14:04:45
【问题描述】:

我正在尝试使用 repo readme 中记录的reveal.js 的pdf 导出选项。

我有以下问题:

  • 我在 chrome 打印窗口中没有看到布局选项(横向与纵向)
  • 打印只打印第一张幻灯片

不知道我做错了什么或如何解决它。我在 example file 上使用来自 Github 的最新版本的reveal.js css 等(sha:131c00689a4c7a18e5c991fc8102347e4594b5d4)。

我在 Ubuntu 14.04 上使用 Google-chrome 版本 34.0.1847.132

【问题讨论】:

    标签: javascript css google-chrome reveal.js


    【解决方案1】:
    1. 删除

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

      <!-- 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. ?print-pdf 添加到 URL 的末尾,例如将.../index.html# 更改为.../index.html?print-pdf#

    【讨论】:

    • 必须更正 css 的链接,恕我直言。目前这似乎是错误的,只需使用 css/print/pdf.css
    • 当我通过 Web UI 将它添加到 HTML 时,我收到“已删除脚本标签在卡组中找到”错误消息。
    • 一行:document.querySelector("[media=print]").removeAttribute("media") ;)
    • 为 ?print-pdf 加一个!我多年来一直试图弄清楚这一点,但似乎无法在揭示网站上找到它(不是说它不存在,只是我无法通过搜索“打印”找到它)。
    【解决方案2】:

    我使用幻灯片制作了一个演示文稿并将其导出为 HTML,但对我来说,William Zhanf 解决方案根本不起作用。我把所有的幻灯片都覆盖了。我就是这样解决的:

    1. here下载pdf.css并将其与html文件放在同一文件夹中。
    2. &lt;/body&gt; 标记之前粘贴William Zhanf sn-p(更改了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>
    
    1. 然后按照相同的说明进行操作:将?print-pdf 添加到 URL 的末尾并从 Chrome 打印为 PDF。

    【讨论】:

    • 我在幻灯片覆盖方面遇到了完全相同的问题。您的解决方案就像一个魅力! :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-24
    • 2015-01-27
    • 2021-01-17
    • 2013-04-29
    • 2020-10-05
    • 1970-01-01
    相关资源
    最近更新 更多