ViewPDF

Summary: 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
Users: (View? / Edit)
Categories: PDF Media Images

Questions answered by this recipe

This recipe is largely non-functioning due to unexpected and intermittent failures. Possible client config, but in any event it is probably not usable.

This section is optional; use it to indicate the types of questions (if any) this recipe is intended to answer. 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.)

Description

View PDF Objects within a page.

Notes

Put 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)

Roadmap

Implement 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 [(approve links) edit diff] for more info on other types.

Release notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

  • 2001-01-22: Initial version. Works. Argument handling is EXTREMELY simple. Anyone want to enhance it a bit?

See also

Contributors

Comments

This space is for User-contributed commentary and notes. Please include your name and a date (eg 2007-05-19) along with your comment. Optional alternative: create a new page with a name like "ThisRecipe-Talk" (e.g. PmCalendar-Talk).

User 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.