一些用户建议,采用某种方式将HTML和wiki页面转换为PDF文件。因此,你会在此网页上找到3种不同的办法来解决同样的问题,另一种是使用pdfdownload,而exporting_pdf你也可能会感兴趣。
为了输出网页到PDF,您需要添加一个按钮到您的wiki。无论您是使用何种PDF转换器,您都需要执行以下修改:
<div class="bar" id="bar_top">
<div class="bar-left" id="bar_topleft">
<?php tpl_button('edit')?>
<?php tpl_button('history')?>
<?php print html_btn('exportpdf',$ID,'',
array('do' => 'export_pdf')) ?>
<!-- inserted line -->
</div>
如果你想要的按钮显示在底部边条中,使用编号= “ bar_bottom ”
inc/lang/en/lang.php(或你使用的其他语言):
$lang['btn_exportpdf'] = 'Export to PDF';
找到这一行:
$ret .= '<input type="submit" value="'.htmlspecialchars($label).'" class="button" ';
然后用下面的代码进行替换:
//这使得插入的图标显示在菜单栏中 if ($name=="exportpdf"){ $ret .= '<input type="image" src="../lib/images/fileicons/pdf.png" value="'.htmlspecialchars($label).'" '; }else{ $ret .= '<input type="submit" value="'.htmlspecialchars($label).'" class="button" '; }
通过PHP脚本使用html2ps只需要更改和添加很少的DokuWiki源代码。
if ($act == 'export_pdf') {header("Location: ".DOKU_BASE .'html2ps/html2ps.php?URL='.urlencode(wl($ID, '',true)) .'&pixels=1024&media=A4&ps2pdf=2&output=0&cssmedia =screen&renderimages=1&scalepoints=1&leftmargin =10&rightmargin=10&topmargin=10&bottommargin=10'); exit; }
如果你想删除wiki的格式结构并发送的原始HTML格式到PDF文件,用如下方法编辑代码:
urlencode(wl($ID, '', true))
⇒
urlencode(wl($ID, '', true).'&do=export_html')
您还可以更改html2ps命令的其他选项,这些内容可以在html2ps网站上找到。我的建议是加上“renderlinks=1”和“method=fastps”(使用ghostscript生成PDF时)。
如果你的WIKI使用https协议, 那么去html2ps的补丁代码.
这似乎只与网页允许匿名的读取有关。
*有人想知道我可以在哪里找到html2ps.php文件?。它不提供这个软件包。 谢谢。