Html2Pdf

Links & Resources

Download

File: http://snorriheim.dnsdojo.com/dokuPlugins/html2pdf.tar.gz

Usage

To use the script, you simply need to call the page passing it a do=export_pdf php argument. The easiest way to implement this is to add a button or similar somewhere in your template design. As an example, I use an extended dokubook for this, and have the following code inserted into the top__nav unordered list in main.php:

  $pdf_plugin = &plugin_load('action','html2pdf');
  if ( $pdf_plugin ) {
    if ( !plugin_isdisabled($pdf_plugin->getPluginName() ) ) {
      print '<li>'.DOKU_LF;
      print '  <a href="';
        echo exportlink($ID, 'pdf');
        print '" class="action tab_pdf" rel="nofollow">Export Pdf</a>'.DOKU_LF;
      print '</li>'.DOKU_LF;
    }
  }

The appropriate bit of css is added for tab_pdf in dokubook_design.css.

Issues

Php

The html2ps script is pretty greedy and you might not have enough memory reserved for the php script. When this happens, it will return with an error stating so. To increase the memory:

Css

The html2pdf script doesn't know how to handle the !important css property so internal links do not get css'd. If you want them to show up as they appear on the web page, go into your template and edit the /lib/tpl/_template/design.css file, looking for the a.wikilink# (where # is 1 or 2) pattern and edit out the !important pieces.