jasper-reports - How to hide/show and image or textField on last page?
问题描述
In Jasper studio how can I disable/show background for a single page in the report.
I want to disable the watermark image which I set in the background for the last page.
解决方案
当您需要将当前页面与总页数进行比较时,我知道的最简单的方法是在元素上使用评估类型“自动”。
变量将在对应于其重置类型的时间进行评估。
解决方案改编自 lucianc 在https://community.jaspersoft.com/questions/514622/print-when-last-page的回答
创建一个包含具有重置类型 Page 的当前页面的变量(因此它在 Auto 作为当前页码时进行评估)
<variable name="currentPageInAutoEval" class="java.lang.Integer" resetType="Page">
<variableExpression>$V{PAGE_NUMBER}</variableExpression>
</variable
在您的元素(文本字段、图像等)上将评估时间设置为“自动”,并在表达式中使用三元运算符
在您的情况下,最后一页上没有图像
<image evaluationTime="Auto">
<imageExpression>$V{currentPageInAutoEval}.equals($V{PAGE_NUMBER}) ? null : yourImage</imageExpression>
</image>
因此 withevalutationTime="Auto"
$V{currentPageInAutoEval}
将被评估为当前页码的 resetType (Page) 和$V{PAGE_NUMBER}
总页数。
推荐阅读
- docker - 有什么方法可以将 docker 容器连接到本地 IP 地址?
- python - ipython 警告消息 - Linux
- ruby - Docker - 在构建时安装的 Ruby 依赖项在容器启动时不可用
- android - 如何使用 json 库在 android 中解析这个 json?
- tensorflow - 如何知道 Tensorflow 实际“看到”了什么?
- php - 如何使插件内的变量可用于functions.php
- json - Spring Boot JSON 过滤器
- lambda - 使用python 2.7使用lambda函数停止AWS极光数据库
- c# - Android Unity 中语音命令的调用函数
- json - 管理来自服务器的响应类型