Howto Host PDF Files on MediaWiki

This is a continuation of my series of posts about MediaWiki on Windows. Previous post’s can be found at :

  1. Installing MediaWiki on Windows Server 2012 R2 Core
  2. Installing VisualEditor for MediaWiki on IIS
  3. Enabling Media / File Uploads For MediaWiki on Windows Server

Enable PDF Filetype for Upload to MediaWiki
Edit your LocalSettings.php file (usually found at the root of your MediaWiki install) – add the following lines at the end of the file.

#### Add Allowed Upload Filetypes ####
$wgFileExtensions[] = 'pdf';

Initally, I thought this would be enough to host PDF files on my wiki – but unfortunately when I added a media entry via the VisualEditor menu, it looked like this :

Screenshot of PDF added to a wiki page via VisualEditor for MediaWiki.
Screenshot of PDF added to a wiki page via VisualEditor for MediaWiki.

I wasn’t happy with this result so found a better method of hosting PDF’s on mediawiki PDF Include Extension.

To enable this extension – all you need to do is create a folder called ‘PDFInclude’ in your extensions directory – download the code and add to a file called PDFInclude.php inside the newly created directory and add the following to the top of your LocalSettings.php file.

## PDF Include Extension
require_once "$IP/extensions/PDFInclude/PDFInclude.php";

Check the Special:Version page of your wiki to ensure the extension has loaded correctly. You can then use it in your wiki pages by using the following syntax :

<pdf width="width" height="height">Path</pdf>
<pdf width="800px" height="1000px"></pdf>

This will give you an embeded PDF document in your wiki and you can control the size etc… see the extensions page for more information.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s