dw2pdf – 导出 pdf 插件
dw2pdf插件用于导出一个wiki页面为一个pdf文件。官网https://www.dokuwiki.org/plugin:dw2pdf
安装
- 下载并安装插件
- 下载mPdf库最新版,替换掉插件自带的
- 修改mpdf/config.php,大致44行,将useAdobeCJK改为true: 此时导出中文正常
- 修改Dokuwiki主题模版,添加导出按钮
// Dokuwiki template // Insert: <form class="button" method="get" action="<?php wl($ID)?>"> <div class="no"> <button type="submit" class="button"> <img src="<?php echo DOKU_BASE?>lib/images/fileicons/pdf.png" alt="PDF Export" /> </button> <input type="hidden" name="do" value="export_pdf" /> <input type="hidden" name="rev" value="<?php global $REV; echo $REV?>" /> <input type="hidden" name="id" value="<?php echo $ID?>" /> </div> </form> // in lib/tpl/dokuwiki/main.php // after <!-- PAGE ACTIONS --> <div id="dokuwiki__pagetools"> <h3 class="a11y"><?php echo $lang['page_tools']; ?></h3> <div class="tools"> <ul> <?php tpl_action('edit', 1, 'li', 0, '<span>', '</span>'); tpl_action('revert', 1, 'li', 0, '<span>', '</span>'); tpl_action('revisions', 1, 'li', 0, '<span>', '</span>'); tpl_action('backlink', 1, 'li', 0, '<span>', '</span>'); tpl_action('subscribe', 1, 'li', 0, '<span>', '</span>'); tpl_action('top', 1, 'li', 0, '<span>', '</span>'); ?> // DW2pdf-Icon will be on the floating menu.
模版语法
<TEXT> The following replacement patterns can be used within the header and footer files.
@PAGE@ – current page number in the PDF @PAGES@ – number of all pages in the PDF @TITLE@ – The article’s title @WIKI@ – The wiki’s title @WIKIURL@ – URL to the wiki @DATE@ – time when the PDF was created (might be in the past if cached) @BASE@ – the wiki base directory @TPLBASE@ – the PDF template base directory (use to reference images) Remark about Bookcreator: The page depended replacements are only for citation.html updated for every page. In the headers and footers the ID of the bookmanager page of the Bookcreator is applied.
@ID@ – The article’s pageID @PAGEURL@ – URL to the article @UPDATE@ – Time of the last update of the article @QRCODE@ – QR code image pointing to the original page url </TEXT>
注意事项
- include插件兼容性
<TEXT> To work with the include plugin you have to add dw2pdf
to its action_plugin_include
supportedModes
member variable
var $supportedModes = array('xhtml', 'metadata','dw2pdf');
Otherwise you may have problems with caching. </TEXT>