Plugins You can find out about all the publicly available Grails plugins.

Pdf Plugin

  • Tags: pdf, report, render
  • Latest: 0.6
  • Last Updated: 08 September 2010
  • Grails version: 1.1 > *
  • Authors: null
8 votes
compile "org.grails.plugins:pdf:0.6"




grails install-plugin pdf
start up your app and go to the pdf.pdfController. You should see the demo.gsp which should give you some working examples. That simple!


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 to do the rendering.

Take a look at the Rendering Plugin for similar functionality.

Authors : Aaron Eischeid, Glen Smith


  • Releases
  • Usage
  • Tag Documentation
  • Issues


Version 0.1 - Nov-2008

Glen did all the initial work to get the essential functionality and initial documentation

Version 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
Version 0.4 - 27-Apr-2009
  • update to new version of XHTMLrenderer and iText
  • ability to use post method on pdfForms (images and external CSS must have absolute URLs)
  • ability to generate pdf from either templates or to go through control action.
  • ability to use on secured applications (must use method="post").
  • project now hosted on GitHub, but rough copy in grails plugin repository (
  • most form elements now simply get ignored instead of throwing errors
Version 0.4.5 - 5-May-2009
(currently available on github) --
  • modify XHTMLrenderer to allow images to be rendered in PDF when relative URL's are used in GSP
  • cleaning tag library code and fixing some minor bugs in tag rendering.
Version 0.6 - 08-Sep-2010
(source on gitHub, but can install from grails SVN repo again)
  • fix brokenness caused by change in way grails render and include tagLibs worked.
  • CSS still needs absolute URLs for images, but gsp can have relative
  • pdfLink tag can now go through controller and action as well, (couldn't get templates working yet.)
  • fix install script for demo files
  • added a few new files that plugins need
  • mild attempt to update demo files


Also See the demo.gsp included with the plugin

designing your 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;

The xhtmlRenderer user guide has some additional info about how to use CSS to control PDF layout.

XHTML form elements get ignored, but occasionally they will cause PDF generation to fail. It's best to leave them out if possible

TagLibs and pdfController are just a fast and dirty way of getting a pdf. In a production environment you probably want to bypass these and build your forms and links more precisely. It is not all that difficult. Essentially you need to pass the pdfService method either a url, or render a Dom as a string with a baseUrl. Use the included controller and demo files as examples.

Tag Documentation


  • 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'
  • pdfController (optional) - If you want to go through controller… like you would expect...
  • pdfAction (optional) - like you would expect...
  • pdfId (optional) - like you would expect...
  • 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'
  • template (optional) - template you want to render as a pdf, method must = post (since 0.4)
  • controller (optional) - requires action method='post' (since 0.4)
  • action (optional) - controller action for rendering PDF (since 0.4)


  • pdfLink still uses limited get method for sending params, and only allows for security if using pdfController/pdfAction params
  • customized xhtmlRenderer uses old iText version causing it to break with newer iText in the export plugin
Please log additional issues on GitHub project page.