gpt4 book ai didi

grails - 如何使用grails导出插件放置pdf的标题中心?

转载 作者:行者123 更新时间:2023-12-02 15:34:30 25 4
gpt4 key购买 nike

我已经通过在grails中使用export-plugin导出了pdf。现在我的问题是将标题放在pdf的中心。我需要在 Controller 中编写哪些代码以对齐此标题中心?

最佳答案

def export={
def data = userService.list(params)
if(params?.format && params.format != "html")
{
response.contentType = grailsApplication.config.grails.mime.types[params.format]
response.setHeader("Content-disposition", "attachment; filename=${params.controller}.${params.extension}")
List fields = ["username","email","clientName","role","status","timeZone"]
Map labels = ["username": "User Name","email":"Email ID","clientName":"Client Name","role":"Role","status":"Status","timeZone":"Time Zone"]
// Formatter closure
def upperCase = { domain, value -> return value.toUpperCase() }
Map formatters = [name: upperCase]
Map parameters = ["column.widths": [0.3, 0.4,0.2,0.3,0.3,0.3]]
exportService.export(params.format, response.outputStream, data.exportData, fields, labels, formatters,parameters)
}
}

关于grails - 如何使用grails导出插件放置pdf的标题中心?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13988400/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com