Clone this wiki locally
Grails PDF Viewer Plugin
This plugin integrates power of Google doc pdf viewer with your application, though this plugin has been created using Grails-1.3.4 but it supports all version from Grails-1.1.
Example - Whenever pdf is attached as attachment to gmail , it gives two options 1) download 2) View When user selects view is opens pdf in GoogleDoc, similar functionality is provided by this plugin. You simply need to provide full path to tag provided by taglib.
- With this plugin end user will be able to read/print pdf, even if pdf reader is not installed on his machine/browser.
- For application security pdf token given to Google expires after first hit. (If opened in Chrome mode token does not expire)
- grails install-plugin pdf-viewer
- sample application can be found at http://github.com/IntelliGrape/Grails-Google-PDF-Viewer-Demo
- Read only code of sample application along with inline plugin can be cloned by git://github.com/IntelliGrape/Grails-Google-PDF-Viewer-Demo.git
- To use this plugin, user needs to use isSupportedByGoogleDocs tag of PdfTaglib , which checks whether doc is supported by Google Doc and if its supported a link is created to Google Docs.
<pdf:isSupportedByGoogleDocs params="['fullPath':fullPath,chrome:true]"> View on Google Docs </pdf:isSupportedByGoogleDocs>
- Here fullPath is full path of file along with its name. For example: /home/username/pdfname.pdf
- param chrome is optional here. if opened in chrome mode , i.e chrome:true , then Pdf is opened with Menu.
- Make sure that action viewPdf of controller pdfViewer is public.
- Since google needs to hit your application, will not work on local machines.
Test For local machine
- Click on the link generated by taglib.
- Remove "http://docs.google.com/viewer?embedded=true&url=" from Url in address bar, hit remaining url (this test does not work for chrome mode).
- If prompt appears for downloading the file, then you can assume that its working fine.
IMPORTANT: Action viewPdf of controller PdfViewer must be public, so that google can access it.