【发布时间】:2021-10-04 09:57:10
【问题描述】:
【问题讨论】:
-
关于该主题还有很多其他答案;你能提供更多关于他们为什么不为你工作的信息吗?示例:stackoverflow.com/questions/29156614/…
-
@Daniel 我需要深入的解释,这里的答案只是一个概述,绿色勾号答案上共享的链接不会引导我到任何地方解释。
标签: grails
【问题讨论】:
标签: grails
我使用 Grails Rendering 插件从 Grails 生成 PDF。易于使用并从 GSP 生成在幕后使用 iText。
https://plugins.grails.org/plugin/grails/rendering
以下是它的调用方式,模板以下划线开头:
response.setHeader('Content-Disposition', 'inline; filename="Case_Summary_'+selectedCase+'.pdf"')
renderPdf(template: "print", model: [selectedCase: selectedCase, locationList: locationList])
这是带有一些 iText 设置的 GSP 顶部:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Case ${selectedCase} Summary</title>
<style type="text/css">
@page {
size: 8.5in 11in;
margin: 0.25in;
counter-increment: page;
@bottom-right { content: "Created <g:formatDate format='MM/dd/yyyy hh:mm a' date="${new Date()}"/>"};
@bottom-left { content: "Page " counter(page);};
}
body {
font-family: 'Arial', 'sans-serif';
font-size: 9pt;
}
</style>
</head>
【讨论】:
也许您可以使用Grails Jasper Plugin 并创建一个与您的 GSP 格式相同的 jasper 报告,然后将其导出为 PDF。
【讨论】: