ViewPDF
(redirected from Cookbook.ViewPdf)
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.
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
- 2001-01-22: Initial version. Works. Argument handling is EXTREMELY simple. Anyone want to enhance it a bit?
See also
Contributors
Comments
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.