Several methods exist to convert your wiki pages to PDFs. See also the full list of plugins tagged 'PDF'.
Plugins that export directly to PDF:
Other ways to generate PDFs:
In order to export your pages to PDF you'll need to add a button to your wiki. Regardless which PDF converter you use, you need to implement the following changes:
lib/tpl/default/main.php
like so: <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>
(If you want the button to appear in the bottom bar use id=“bar_bottom”
)
inc/lang/en/lang.php
(or whatever language you use):$lang['btn_exportpdf'] = 'Export to PDF';
Search for this line
$ret .= '<input type="submit" value="'.htmlspecialchars($label).'" class="button" ';
and replace with this.
//This allows the insertion of an icon in the menu bar 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" '; }
In order to have an export-link below the “Back to top”-link do the following:
inc/lang/de/lang.php
(or whatever language you use):$lang['btn_export_pdf'] = 'Als PDF exportieren';
lib/tpl/dokuwiki/main.php
<!-- 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>'); tpl_action('export_pdf',1, 'li', 0, '<span>', '</span>'); <!-- inserted line --> ?> </ul> </div> </div>
function tpl_get_action($type)
in file inc/template.php
and add the following condition:case 'media': $params['ns'] = getNS($ID); break; case 'export_pdf': <!-- inserted line --> break; <!-- inserted line --> default: return '[unknown %s type]'; break; } return compact('accesskey', 'type', 'id', 'method', 'params'); }
export_pdf
css-actions for the image in lib/tpl/dokuwiki/css/pagetools.css
and add them at the end of the file#dokuwiki__pagetools ul li a.export_pdf { background-position: right -270px; } #dokuwiki__pagetools ul li a.export_pdf:before { margin-top: -270px; } #dokuwiki__pagetools ul li a.export_pdf:hover, #dokuwiki__pagetools ul li a.export_pdf:active, #dokuwiki__pagetools ul li a.export_pdf:focus { background-position: right -315px; }
Q: Where I will find required file /lib/plugins/pdf/renderer.php (and rest of files from /lib/plugins/pdf/) ?
A: If you follow the guide htmldoc then it wont complain about these missing files, as the system will not try to start a “pdf” plugin
Using the html2ps PHP script requires only little changes and additions to the DokuWiki source code.
act_export
, in inc/actions.php
, add this: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; }
If you want to remove the wiki structures and send the raw html page to the pdf exporter, edit the above so that
urlencode(wl($ID, '', true))
⇒
urlencode(wl($ID, '', true).'&do=export_html')
You may also wish to vary other options for the html2ps command, these can be found in the documentation on the html2ps site. I add renderlinks=1 and method=fastps (for building using ghostscript) to mine.
If your Wiki uses HTTPS, then get the patch for html2ps.
This appears to only work with pages that allow anonymous read access.
GIF images are not embedded into the generated PDF, instead only the first frame is shown.
*Is-someone knows where I can found the html2ps.php file ?. It's not provided with the package. Thanks. The file is in the Demo directory. Use the index file and the single URL convert to test your website before. My Website is Strict XHTML but looks horrible in PDF. Best regards from Germany.