PDF: Difference between revisions

From Meta, a Wikimedia project coordination wiki
Content deleted Content added
New page: ==PDF extension== Copy the code in to pdf.php and add the following string to LocalSettings.php require ("extension/pdf.php"); This will include a PDF file to you media wiki <?php // ...
 
Transwiki'd
 
(7 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{MovedToMediaWiki|Extension:PDF}}
==PDF extension==
Copy the code in to pdf.php and add the following string to LocalSettings.php

require ("extension/pdf.php");

This will include a PDF file to you media wiki

<?php
// MediaWiki PDF Extension Ver 0.1
// Set up MediaWiki to react to the "<PDF>" tag
// Original file by Nilam Doctor
// <ceo@qualifiedtutorsinc.com> to allow local PDF files
$wgExtensionFunctions[] = "wfPDF";
function wfPDF() {
global $wgParser;
$wgParser->setHook( "pdf", "RenderPDF" );
}
function RenderPDF( $input, $argv ) {
global $wgScriptPath;
$output = "";
// external URL
if ( strpos($input , "http") === 0 && strpos($input, ".pdf") == strlen($input)-4 ) {
$url = $input;
}
// internal Media:
else {
$url = $input;
}
$width = isset($argv['width']) ? $argv['width'] : 800;
$height = isset($argv['height'])? $argv['height'] : 600;
$id = basename($input, ".pdf");
$output .=<<<EOM
<IFRAME width=800 height=600 SRC="$url" FRAMEBORDER=0 FRAMEBORDERCOLOR="#000000"></IFRAME>
EOM;
$output = str_replace("\n", "", $output);
return $output;
}

?>

Latest revision as of 06:50, 27 June 2008