I am working with ColdFusion Report Builder for CF9 and trying to pass a chart into a report as a PNG image. Here's my CFML code:
<cfchart format="png" name="chartImage">
<cfchartseries type="bar" query="chart" itemcolumn="title" valuecolumn="level">
</cfchart>
<cfreport format="pdf" template="report.cfr" name="grid">
<cfreportparam name="reportTitle" value="#reportType.title#">
<cfreportparam name="chartImage" value="#chartImage#">
</cfreport>
In CF Report Builder I have defined an Input Parameter called chartImage
and set it to a type of BLOB
(also tried type Image
), following these instructions exactly.
I am getting this error and haven't been able to overcome it:
Report data binding error Incompatible [B value assigned to parameter chartImage in the ColdFusionReport dataset..
I've also changed the parameter type to String
, passed in a base-64 string and then converted it to binary within the report, but that throws an error with an unhelpful message of [B
.
How can I get this image to bind correctly as an input parameter?
I suppose the lack of interest in this question speaks to the popularity of CF Report Builder. While I have not been able to overcome the binding error, I did find a reasonable workaround.
Instead of directly binding the image as a binary value, I am writing the chart image to the temp directory and then passing that path into the report as a string parameter. The report then can find the image from the file system and attach it to the report without any trouble. Once the report has been run, I delete the chart from the file system to ensure everything stays nice and tidy.
Here's the updated code with this solution:
It's not very elegant, but nothing about CF Report Builder has been particularly elegant.