[英]Grails Rendering plugin converting html/gsp from the cloud or from string
Currently examples from the Grails rendering plugin documentation shows this: 当前,Grails渲染插件文档中的示例显示了这一点:
pdfRenderingService.render(template: "/pdfs/report", model: [data: data]) pdfRenderingService.render(模板:“ / pdfs / report”,模型:[数据:数据])
The problem is that the html template I need to render to pdf
is in a database. 问题是我需要渲染为pdf
的html模板在数据库中。 Is it possible to use a url (or maybe an html string) as a source of the template? 是否可以使用url(或html字符串)作为模板的来源?
This should do the trick; 这应该可以解决问题; you need to build the Document
manually and pass it into render
: 您需要手动构建Document
并将其传递给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. 其中“”是您要呈现的html标记的字符串版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.