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

Wkhtmltopdf Plugin

  • Tags: pdf, utility
  • Latest: 0.1.8
  • Last Updated: 12 February 2015
  • Grails version: 2.0 > *
2 votes
compile ":wkhtmltopdf:0.1.8"

 Documentation  Source  Issues


Provides a Wrapper for wkhtmltopdf, a simple shell utility to convert HTML to PDF using the WebKit rendering engine and Qt


grails install-plugin wkhtmltopdf


Grails Wkhtmltox / Wkhtmltopdf

This plugin provides an easy integration of the wkthmltox library into Grails.


"Simple shell utility to convert html to pdf using the webkit rendering engine, and qt." GNU Lesser GPL



brew install wkhtmltopdf


apt-get install wkhtmltopdf



put the following line into your Config.groovy and adjust the path to your wkhtmltox binary ( which wkhtmltopdf )

grails.plugin.wkhtmltox.binary = "/usr/bin/wkhtmltopdf"


to stream the content of an controller-action as pdf just call: /context/some/someAction.pdf

class SomerController {
        def someAction = {
            def someInstance = SomeDomainObject.get(

render( filename:"File ${}.pdf", view:"/some/someGspTemplate", model:[someInstance:someInstance], header:"/pdf/someHeader", footer:"/pdf/someFooter", marginLeft:20, marginTop:35, marginBottom:20, marginRight:20, headerSpacing:10, ) } }

Or create binary pdf data and use them for any other purpose
class SomeService implements Serializable {

def byte[] pdfData = wkhtmltoxService.makePdf( view: "/pdf/someGspTemplate", model: [someInstance: someInstance], header: "/pdf/someHeader", footer: "/pdf/someFooter", marginLeft: 20, marginTop: 35, marginBottom: 20, marginRight: 20, headerSpacing: 10, )

// DO Something e.g. send as mail //sendAsynchronousMail { // multipart true // to "[email protected]" // subject "see PDF Attachment"; // attachBytes "PDF Attachment.pdf", "application/x-pdf", pdfData // body "see my pdf attachment" //} } }

write your gsps as usual, just make sure, that the url's to the resources are absolute and reachable by the host maschine
<link rel="stylesheet" href="${resource(dir: '/css/style.css', absolute: true)}" type="text/css"/>
	<img src="${resource(dir: '/images/image.jpg', absolute: true)}" width="200px"/>


see the following command for all options available:

wkhtmltopdf --extended-help

Known issues

  • wkhtmltox must work ( try: ```wkhtmltopdf myhomepage.pdf``` see: )
  • not tested on Windows