gpt4 book ai didi

grails - 如何在 grails 中使用渲染插件

转载 作者:行者123 更新时间:2023-12-01 15:26:39 24 4
gpt4 key购买 nike

我正在使用渲染插件创建 PDF。该插件工作正常。但是,当我点击下载为 PDF 时。它将我重定向到另一个页面:

Screenshot of the other page

它给了我一个 PDF 格式的结果,然后它给了我一个选项,可以像这张图片一样保存: Screenshot of saving as PDF

但我想要的是当我点击下载为 PDF 按钮时: Download button

它将直接向我显示一个保存窗口,而不是将我重定向到另一个页面。

我的代码:

def renderFormPDF(Long id){
def empinstance= emp.get(id)
renderPdf(template:"view", model:[empinstance:empinstance, pdfRendering:true])

}

最佳答案

试试这个

def renderFormPDF(Long id){
def empinstance= emp.get(id)

response.setContentType("application/pdf")
response.setHeader("Content-Disposition", "attachment; filename=fileName.pdf")

renderPdf(template:"view", model:[empinstance:empinstance, pdfRendering:true])
}

关于grails - 如何在 grails 中使用渲染插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17963389/

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