|
Cookbook /
ViewPDFSummary: Embed PDF files in a wiki page
Version: 2010-01-22
Prerequisites: Clients must have the software configured for handling the object (PDF viewer in this case)
Status: Experimental
Maintainer: Peter Bowers
Questions answered by this recipeThis recipe is largely non-functioning due to unexpected and intermittent failures. Possible client config, but in any event it is probably not usable. How can I embed PDF documents in my page? See http://pmwiki.qdk.org/Test/Pdf for a sandbox. (Although it is a development version rather than the more stable version here.) DescriptionView PDF Objects within a page. NotesPut this code in your config.php:
Markup('pdf', 'inline',
'/\(:pdf\s+(\S*)\s*(.*?):\)/ie',
'viewpdf($pagename, "$1", "$2")');
function viewpdf($pagename, $data, $args)
{
global $UploadFileFmt;
$datafile=FmtPagename($UploadFileFmt, $pagename).'/'.$data;
$arglist = ParseArgs($args);
echo "arglist=".print_r($arglist,true)."<br>\n";
$dataargs = '';
foreach ($arglist as $var => $val) {
if ($var != '#') {
if (in_array($var, array('navpanes', 'toolbar', 'scrollbar')))
$dataargs .= ($dataargs?'&':'#').$var.'='.$val;
else
$normargs .= ' '.$var.'="'.$val.'"';
}
}
return("<object type=\"application/pdf\" data=\"".$datafile.$dataargs."\" $normargs>(You do not have a PDF Reader configured correctly on your machine. Click <a href=\"$datafile\">here</a> to download and view the file.)</object>");
}
Source on your page will look like this: (:pdf foo.pdf width="500" height="650" :) If you don't want navpanes, toolbar, etc it might look like this: (:pdf foo.pdf navpanes=0 toolbar=0 width="500" height="650" :) See here for more allowed parameters: http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf (only toolbar and navpanes and scrollbar implemented at this point) RoadmapImplement more of the special PDF arguments... It would be nice to have some cleaner defaults as well... (maybe default to no navpanes/toolbar?) Probably ought to be put into its own php script rather than just dumped in config.php... See this: http://blog.flashcolony.com/?p=244# if you want to see HTML examples of how it works. It would be pretty easy to expand this to use other objects of other mime types. Word files, etc. just don't want to get too complicated. See http://joliclic.free.fr/html/object-tag/en/(approve links) for more info on other types. Release notes
See alsoContributorsCommentsUser notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |