Last updated by menilub 2 years ago
PDF plugin
Pdf plugin allows your Grails application to generate PDFs and send them to the browser by converting existing pages in your application to PDF on the fly. The underlying system uses the xhtmlrenderer component from java.net to do the rendering.Authors : Glen Smith, Aaron EischeidIndex
- Releases
- Usage
- Tag Documentation
- Issues
Releases
Version 0.1 - Nov-2008
Glen did all the initial work to get the essential functionality and initial documentationVersion 0.2 - 14-Feb-2009
First release to Grails repositories!Aaron did some reworking of the tagLibraries and controllers and also improved on the documentation. The most significant addition was the ability to use simple forms.Version 0.3 - 20-Feb-2009
new features:
- graceful failing - if PDF generation fails for some reason you get the HTML view instead of an error page.
- pdfLink accepts class attribute for custom styling
- improved examples and docs
-compatibility with grails 1.1 (maybe already is… just not tested)Version 0.4+ - ??
features being worked on for future releases:
- appending existing pdf files to the pdf that is generated
- use of post method on pdfForms
- ability to use on secured applications
Usage
Also See the demo.gsp included with the plugin
install
grails install-plugin pdf
Design the GSP just like normal. Separate style sheets for media="print" and media="screen" are a good idea. You can use the CSS 3 @page to define page layout and margins.
@page {
size: 8.5in 11in; /* width height */
margin: 0.25in;
}Tag Documentation
g:pdfLink
attributes:
- url (required) - the url of the gsp to want to convert to PDF
- filename (optional) - what you want the filename of the resultant PDF to be - defualt = 'document.pdf'
- icon (optional) - will add and <img … /> tag
- class (optional) - set the class of element - default = 'pdf'
attributes:
- url (required) - the url of the gsp to want to convert to PDF
- filename (optional) - what you want the filename of the resultant PDF to be
- name (optional) - becomes the name and id of HTML form - default = 'simplePdfForm'
- method (optional) - the method of the form - default = 'get' (post doesn't work yet.)
Issues
- pdfForm uses get method which is very limited.
- in generating the pdf the controller does not have access to session or flash data. This poses serious problems if you are using security.
auth(controller: "*", action: "*") { before = { // Exclude the "public" controller. // if (controllerName == "public") return true if(controllerName == 'pdf') return true if(actionName == '[yourAction]') return true // This just means that the user must be authenticated. He does // not need any particular role or permission. accessControl { true } } }
- not tested in grails 1.1



