Image in collection parameter rendering with base64 image data
nhitchins opened this issue · 2 comments
nhitchins commented
Exception thrown rendering an image document element with its source
set to an image parameter inside a collection parameter. eg. ${Collection.Img}
. The data
provided includes a b64 encoded string eg. {"Collection": {"Img": "data:image/png;base64,...."}}
.
Reportbro-lib version 1.5.1
report_definition = {
"docElements":[{"elementType":"image","id":3,"containerId":"0_content","x":40,"y":130,"width":80,"height":80,"source":"${Collection.Img}","image":"","imageFilename":"","horizontalAlignment":"left","verticalAlignment":"top","backgroundColor":"","printIf":"","removeEmptyElement":false,"link":"","spreadsheet_hide":false,"spreadsheet_column":"","spreadsheet_addEmptyRow":false}],
"parameters":[{"id":1,"name":"Collection","type":"map","arrayItemType":"string","eval":false,"nullable":false,"pattern":"","expression":"","showOnlyNameType":true,"testData":"","children":[{"id":2,"name":"Img","type":"image","arrayItemType":"string","eval":false,"nullable":false,"pattern":"","expression":"","showOnlyNameType":false}]}],
"styles":[],
"version":3,
"documentProperties":{"pageFormat":"A4","pageWidth":"","pageHeight":"","unit":"mm","orientation":"portrait","contentHeight":"","marginLeft":"","marginTop":"","marginRight":"","marginBottom":"","header":true,"headerSize":"80","headerDisplay":"always","footer":true,"footerSize":"80","footerDisplay":"always","patternLocale":"en","patternCurrencySymbol":"$"}
}
data = {"Collection": {"Img": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="}}
Traceback (most recent call last):
File "report_build.py", line 52, in <module>
app = run_app()
File "report_build.py", line 36, in run_app
reportBytes = report.generate_pdf()
File "/reportbro/reportbro.py", line 614, in generate_pdf
return renderer.render()
File "/reportbro/reportbro.py", line 79, in render
self.content_band.prepare(self.context, self.pdf_doc)
File "/reportbro/containers.py", line 36, in prepare
elem.prepare(ctx, pdf_doc=pdf_doc, only_verify=only_verify)
File "/reportbro/elements.py", line 65, in prepare
str(Context.get_parameter_context_id(param_ref))
File "/reportbro/context.py", line 101, in get_parameter_context_id
return param_ref.data['__context_id']
KeyError: '__context_id'
It appears that the call to get_parameter_context_id
is failing as no __context_id
has been assigned to children of ParameterType.map in evaluate_parameters
.
alhman commented
What exception is thrown? Which reportbro-lib version are you using?
Image parameters inside collections was fixed in v1.5.0
nhitchins commented
Updated issue