碧玉报告pdf导出中忽略了半透明(半透明)背景色 [英] Semi-transparent (translucent) background color ignored in jasper reports pdf export

查看:121
本文介绍了碧玉报告pdf导出中忽略了半透明(半透明)背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问:保存为PDF时为什么会丢失alpha信息?

Q: Why is the alpha information lost when saving to PDF?

Jaspersoft studio不允许我使用alpha指定颜色。因此,我尝试变得聪明并在阴影元素上指定了键,并在代码中更改了颜色,如下所示:

Jaspersoft studio doesn't allow me to specify colors with alpha. So I tried to be clever and specified keys on my shading elements and changed the color in the code like so:

JasperReport jasperReport = (JasperReport) JRLoader.loadObject(getClass().getResourceAsStream("/reports/Test.jasper"));
((JRStaticText) jasperReport.getGroups()[0].getGroupHeaderSection().getBands()[0].getElementByKey("bg")).setBackcolor(new Color(0, 0, 0, 30));
((JRRectangle) jasperReport.getGroups()[0].getGroupFooterSection().getBands()[0].getElementByKey("bg")).setBackcolor(new Color(0, 0, 0, 30));

只是看看是否有所作为,我同时使用了JRStaticText和JRRectangle。预览和纸上的实际打印效果看起来很棒。当我打印到PDFCreator时,它也可以工作。但是,当我从JRViewer / JasperViewer保存为PDF时,生成的PDF会显示为不透明的黑色。

Just to see if it makes a difference I used both JRStaticText and JRRectangle. The preview and the physical printout on paper look great. It also works when I print to PDFCreator. But when I save to PDF from the JRViewer/JasperViewer, the resulting PDF appears with opaque black.

预览/纸张打印/ PDFCreator:

Preview/Paper print/PDFCreator:

碧玉报告PDF保存/导出:

Jasper reports PDF save/export:

推荐答案

显然,Jasper Reports不支持此功能。

Apparently this feature is not supported by Jasper Reports.

Jasper Studio 6.1甚至允许在背景色对话框中指定文本字段透明级别,只是在对话框被确定后立即丢失该值。

Jasper Studio 6.1 even allows to specify a Text field transparency level in the background color dialog box, only to lose the value as soon as the dialog is given the OK.

我们实现的解决方案是将文本与先前准备的半透明图像重叠。

The solution we implemented was to overlap the text with a semi-transparent image prepared previously.

这篇关于碧玉报告pdf导出中忽略了半透明(半透明)背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆