Questions answered by this recipe
How can I embed PDF, PPT, DOC, or TIFF files in a wiki page?
GoogleViewer supports embedding PDF documents, PowerPoint presentations, Microsoft Word .doc files, and TIFF files on a wiki page. They may be hosted on your own wiki website, or on GoogleDocs, or elsewhere on the web. It is not necessary to have a Google account to use the viewer services. For more info on Google Viewer, visit http://docs.google.com/viewer.
A Note on Supported Formats
The GoogleViewer page listed above states that "PDF documents, PowerPoint presentations, and TIFF files are supported." In addition, experimentation shows that it also seems to support DOC and ODT files as well. RTF files, however, seem to fail, and quite strangely I've found that PPT files exported from GoogleDocs occasionally seem to fail, while the same PPT opened and then saved with OpenOffice/NeoOffice works! So, if at first you don't succeed, save save again ... from another program, or in a different format. overtones99 December 22, 2010, at 07:16 PM
To install, include GoogleViewer.phpΔ in
You must also define
(the path to your uploads directory) and
config.php before including your recipe. If these haven't already been defined, your installation may look like:
$group = PageVar(
The most basic syntax is:
The filename can be provided in several formats:
(:googleviewer http://blah.com/myfile.pdf:)- view a file hosted on an external site, using a full url
(:googleviewer testfile.pdf:)- view a file in the current group
(:googleviewer Group/testfile.pdf:)- view a file in another group on the same wiki
4 optional parameters are available:
(:googleviewer myfile.pdf width=... height=... embedded=... style=...:)
- width - (default: 600) - can be included as a pixel-value (i.e. width="500"), or as a fluid percentage value (i.e. width="100%")
- height - (default: 780) - only seems to respond intuitively to a pixel-value: i.e. height="600"
- embedded - (default: true) - when set to 'true', the pdf shows up as a single page, and all icons are small and listed at the top; when set to 'false', more of the GoogleDocs interface emerges, such as the "download" and "print" links at the top, a large GoogleDocs icon/link, and most notably the column on the right showing thumbnails of all the pages, with navigation tools. This latter setting is probably most useful for a long document where nonlinear navigation is of importance.
- style - css style information can be provided, i.e. style="border:5px dotted red;"
To define different wiki-wide default values, declare something like this in config.php before including the recipe:
$GoogleViewerDefaults['width'] = '100%';
$GoogleViewerDefaults['height'] = '1000';
For the sake of comparison (not competition : ) to other recipes or pdf-viewing services, it's worth pointing out that:
- this recipe does NOT require visitors to have the Adobe PDF Viewer Plugin installed in their browser (as does ViewPDF)
- the files you want to view can be stored anywhere, and needn't be uploaded to Google Docs or even to your own site (I may be incorrect, but it seems that most services like Scribd require you to upload files to their site in order to then embed and view them on yours...)
- the GoogleViewer displays PDFs, PowerPoints, .doc, and TIFF files, while ViewPDF only display PDFs
- some of the fonts look absolutely horrible!
- many of the images seem to be majorly pixelated, dithered, ugly - YUCK! : (
- 2010-05-16 - added parameter "embedded="
- 2010-01-23c - fixed bug that prevented recipe from working for users with per-page-uploads (
$UploadFileFmt = '$Group/$Name'; the globals
$UploadUrlFmtare no longer needed for this recipe
- 2010-01-23 - initial release (overtones99) (feel free to improve upon this recipe)
- Scribd - Embed Scribd documents & pdfs on a webpage
- ViewPDF - recipe by Peter Bowers that uses the Adobe PDF Plugin to embed pdfs
- PmDocConvert - PmDocConvert makes it easy to upload and display formats that can be handled by OpenOffice.org on a PmWiki page.
- Ape - embed a PDF on a page using the Google Docs service
See discussion at GoogleViewer-Talk
User notes +4: 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.