====== 将DokuWiki页面输出为PDF ====== 一些用户建议,采用某种方式将HTML和wiki页面转换为PDF文件。 Current pdf export plugins: * [[plugin:dw2pdf]] * [[plugin:pdfex]] (old) * [[plugin:html2pdf]] (broken) You can also see: * html to pdf converter: [[tips:pdfexport:HTMLDOC]], * or generate OpenOffice documents from your wiki using [[plugin:odt]]-plugin, as OpenOffice provides native export to PDF (working hyperlinks, tables, images and more). ===== 共同的修改 ===== 为了输出网页到PDF,您需要添加一个按钮到您的wiki。无论您是使用何种PDF转换器,您都需要执行以下修改: \\ * 编辑"lib/tpl/main.php",添加一个 //Export to PDF// 按钮, 如下:
'export_pdf')) ?>
如果你想要的按钮显示在底部边条中,使用编号= “ bar_bottom ” * 添加一个新的字符串到''inc/lang/en/lang.php'' (或你使用的其他语言): $lang['btn_exportpdf'] = 'Export to PDF'; * 为了显示上述“exportpdf”的PDF图标 ,请在"inc/html.php"文件中执行以下操作: 找到这一行: $ret .= ' 然后用下面的代码进行替换: //这使得插入的图标显示在菜单栏中 if ($name=="exportpdf"){ $ret .= ' ===== html2ps PHP 脚本 ===== 通过PHP脚本使用html2ps只需要更改和添加很少的DokuWiki源代码。 * 安装[[http://www.tufat.com/script19.htm|html2ps]].(运行这个php脚本你需要事先安装ghostscript或 libpdf) * 添加上述的//Export to PDF//按钮. * 在"inc/actions.php"文件的"act_export"子程序中,添加: 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时)。 ====html2ps的其他话题==== 如果你的WIKI使用https协议, 那么去[[http://www.tufat.com/resources.php?dl=274|html2ps的补丁代码]]. ==== 问题 ==== 这似乎只与网页允许匿名的读取有关。 ---- ---- ---- *有人想知道我可以在哪里找到html2ps.php文件?。它不提供这个软件包。 谢谢。