[英]Including dynamic images in a PDF with BIRT
I am trying to use BIRT 2.5.0 to generate a pdf file.我正在尝试使用 BIRT 2.5.0 生成一个 pdf 文件。 BIRT is called from pHp (this is done thanks to JavaBridge and a Tomcat server). BIRT 从 pHp 调用(这要归功于 JavaBridge 和 Tomcat 服务器)。
And I am simply trying to create a checkbox, checked under certain conditions.我只是想创建一个复选框,在特定条件下选中。 I looked a bit on the inte.net and found 2 different ways to do it.我在 inte.net 上看了看,发现了两种不同的方法。
The first way is to play with the Visibility if the field "idclassebillet" (on which I am making the test) has a value of 1. I did it this way:第一种方法是在字段“idclassebillet”(我正在对其进行测试)的值为 1 时使用可见性。我是这样做的:
<image id="9010">
<list-property name="visibility">
<structure>
<property name="format">all</property>
<expression name="valueExpr" type="javascript">row["classEq1"]</expression>
</structure>
</list-property>
<list-property name="boundDataColumns">
<structure>
<property name="name">classEq1</property>
<text-property name="displayName">classEq1</text-property>
<expression name="expression" type="javascript">dataSetRow["idclassebillet"] == 1</expression>
<property name="dataType">boolean</property>
</structure>
</list-property>
<property name="source">embed</property>
<property name="imageName">checkbox_unchecked.png</property>
</image>
But this doesn't work.但这不起作用。
So the second solution that I found was to play with a simple URL. This solution is much more convenient, but doesn't work neither.所以我找到的第二个解决方案是使用一个简单的 URL。这个解决方案更方便,但也不起作用。 This would looks like that.这看起来像那样。
<image id="9018">
<property name="source">url</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">classEq1</property>
<text-property name="displayName">classEq1</text-property>
<expression name="expression" type="javascript">dataSetRow["idclassebillet"]</expression>
<property name="dataType">integer</property>
</structure>
</list-property>
<expression name="uri" type="javascript">
if(row["classEq1"] == 1)
"http://my.server.com/checkbox_checked.png"+row["classEq1"];
else
"http://my.server.com/checkbox_unchecked.png"+row["classEq1"];
</expression>
</image>
In both cases, I declare the field "dataSetRow["idfield"]" like that:在这两种情况下,我都这样声明字段“dataSetRow[“idfield”]”:
<data-sets>
<oda-data-set extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" name="infoBordereau" id="178">
<structure name="cachedMetaData">
<list-property name="resultSet">
...
<structure>
<property name="position">9</property>
<property name="name">idclassebillet</property>
<property name="dataType">integer</property>
</structure>
...
</structure>
<property name="dataSource">GestionBillet</property>
<list-property name="resultSet">
...
<structure>
<property name="position">8</property>
<property name="name">idclassebillet</property>
<property name="nativeName">idclassebillet</property>
<property name="dataType">integer</property>
</structure>
...
</list-property>
....
</oda-data-set>
</data-sets>
I checked that I can access to the content of "idclassebillet".我检查了我是否可以访问“idclassebillet”的内容。 If I simply print it this way, it works fine:如果我只是这样打印它,它就可以正常工作:
<data id="90060001">
<property name="whiteSpace">nowrap</property>
<property name="dataSet">infoBordereau</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">classEq1</property>
<text-property name="displayName">classEq1</text-property>
<expression name="expression" type="javascript">dataSetRow["idclassebillet"]</expression>
<property name="dataType">integer</property>
</structure>
</list-property>
<property name="resultSetColumn">classEq1</property>
</data>
And whatever the solution I choose to get my "dynamic" images, I always get the same image, whatever the value of "dataSetRow["idclassebillet"]" is.无论我选择何种解决方案来获取“动态”图像,我总是得到相同的图像,无论“dataSetRow["idclassebillet"]”的值是多少。 I have no problem accessing and printing the image.我可以毫无问题地访问和打印图像。 The problem is more to "test" the value of the "idclassebillet" field (ie. how can I access this field?).问题更多是“测试”“idclassebillet”字段的值(即我如何访问该字段?)。
I hope that you understand what I am trying to do.我希望你明白我想做什么。 If you have a better solution (and if possible an example of working code), don't hesitate to share ^^:)如果您有更好的解决方案(如果可能的话,还有一个工作代码示例),请不要犹豫,分享 ^^:)
Many thanks,非常感谢,
Raphaël POITTEVIN拉斐尔·波特文
NB: At first, I wanted my images to be embedded in the document (this what I use in the first solution), but as this didn't worked, I used an images hosted on http://my.server.com ...注意:起初,我希望我的图像嵌入到文档中(这是我在第一个解决方案中使用的),但由于这不起作用,我使用了托管在http://my.server.com上的图像。 ..
If your objective is to display an unchecked/checked checkbox, have you considered using the Wingdings font with characters 0xA8 and 0xFD or 0xFE?如果您的目标是显示未选中/选中的复选框,您是否考虑过使用带有字符 0xA8 和 0xFD 或 0xFE 的 Wingdings 字体?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.