Install MediaWiki Extension PDF Export with HTMLDoc

Friday, April 5, 2013
Mediawiki support download as PDF option with use of an extension PDF Export. This post shows step-wise process to install HTMLDoc to your mediawiki. the following example is done on Ubuntu.

  1. Install HTMLDoc in ubuntu
    sudo apt-get install htmldoc
  2. Download PHP Export 
  3. sudo apt-get install git
    cd /var/www/www.example.com/wiki/extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/PdfExport
    
  4. Edit Localsettings.php in /var/www/www.example.com/wiki/ and add
    require_once("$IP/extensions/PdfExport/PdfExport.php");
    #$wgPdfExportHtmlDocPath = '/usr/local/bin/htmldoc'; This path may change according to system
    $wgPdfExportHtmlDocPath = '/usr/bin/htmldoc';
    
    Note: to know your bin path in linux type 'echo $PATH'.
  5. First three steps complete PDF Export installation process. If you test any article in your mediawiki, it will show Print as PDF option. But If you open  PDF, the title of the page will be with underscore instead of spaces and font will be default. So further editing is required to make it look better.
    cd PdfExport
    And Edit PdfExport_body.php
  6. Find
    'fontface'      => 'times',
    And Replace with
    'fontface'      => 'helvetica',
  7. Then:
    cd converters
    And Edit HtmlDocPdfConverter.php.
  8. Find
    <title>".utf8_decode($page)."</title>
    And Replace with
    <title>".utf8_decode($title)."</title>
Here the installation and configuration is complete. For further support read:
http://www.mediawiki.org/wiki/Extension:Pdf_Export
http://tecfa.unige.ch/guides/utils/htmldoc/htmldoc.pdf


No comments: