【问题标题】:How to add dynamic image in jasper report using jasper studio [duplicate]如何使用jasper studio在jasper报告中添加动态图像[重复]
【发布时间】:2018-10-23 02:48:16
【问题描述】:

如何使用jasper studio在jasper报表中添加动态图片。数据库是postgresql

图片以bytea格式存储

如何在 jasper 报告中显示该图像。

如何解决这个问题?还有其他方法吗?

数据库查询 ->

select encode(image,'escape') as img,id from entity_image where entity_id = 100

图像表达-> new java.io.ByteArrayInputStream(org.apache.commons.codec.binary.Base64.decodeBase64($F{image}.getBytes()))

【问题讨论】:

  • 你能分享一下你到目前为止所尝试的吗?
  • 数据库查询-> select encode(image,'escape') as img,id from entity_image where entity_id = 100 image expression-> new java.io.ByteArrayInputStream(org.apache.commons.codec .binary.Base64.decodeBase64($F{image}.getBytes()))
  • 你可以添加这个问题吗?
  • 您不需要对 bytea 数据进行编码/解码。只需选择 image as img ...,将字段类型设置为 java.awt.Image 并使用 $F{image} 作为图像表达式。

标签: jasper-reports


【解决方案1】:

您不需要对 bytea 数据进行编码/解码。

直接选择select image, id ...中的bytea列,设置字段类型为java.awt.Image,使用$F{image}作为图片表达方式。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多