0

Currently examples from the Grails rendering plugin documentation shows this:

pdfRenderingService.render(template: "/pdfs/report", model: [data: data])

The problem is that the html template I need to render to pdf is in a database. Is it possible to use a url (or maybe an html string) as a source of the template?

Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102
froi
  • 7,268
  • 5
  • 40
  • 78

1 Answers1

0

This should do the trick; you need to build the Document manually and pass it into render:

XhtmlDocumentService xhtmlDocumentService
def methodName() {
    def document = xhtmlDocumentService.createDocument("<html>")
    pdfRenderingService.render([model: [data: data]], document)
}

where "" is the string version of the html markup you want to render.