初投稿。
crowiには、プレゼンテーションモードはあるけど、pdf出力する機能はない。
プレゼンテーションモードにはreveal.jsを利用しているみたいですが、URLの末尾に?print-pdf
を付けても印刷用表示にならなかったため、それの対処法。
原因
reveal.jsのreadmeにも書いてありますが、以下のscript文が書かれていないため、印刷用表示にならない。
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
また、print-pdf
指定時の読み込みCSSの場所も変更しておかなければならないため、最終的には以下の行をプレゼンテーションモードのviewページ(/lib/views/page_presentation.html)に追記してあげる必要がある。
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? '/js/reveal/css/print/pdf.css' : '/js/reveal/css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
自分の環境では、docker-hubにあったcrowiのイメージをそのまま建てただけなので、viコマンドやボリュームをホストとマウントしていなかったため、しぶしぶsedコマンドで対応した。
# cp lib/views/page_presentation.html lib/views/.page_presentation.html.backup
# cat lib/views/page_presentation.html | sed "14 i <script>\nvar link = document.createElement( 'link' );\nlink.rel = 'stylesheet';\nlink.type = 'text/css';\nlink.href = window.location.search.match( /print-pdf/gi ) ? '/js/reveal/css/print/pdf.css' : '/js/reveal/css/print/paper.css';\ndocument.getElementsByTagName( 'head' )[0].appendChild( link );\n</script>\n" > lib/views/page_presentation.html
一応、元のファイルをcp
コマンドで.page_presentaition.html.backupで退避しています。
別にこんなまどろっこしい事しなくてもpage_presentation.htmlの<title>
の上辺りに書けば多分動きます。