El 07/12/17 a les 13:35, edbo.des...@gmail.com ha escrit:
Hello All,

We want to add dynamically created images to a report, but we can't get it 
working :-( . It's a generated 2D-barcode based on a product code. We added a 
frame an added on tab Options as name image: (record.barcode, 'image/png'), but 
we only get a strange line and not a 2D-barcode.
We also added a binary-field to the product to see if that was going to work, 
but we get the same result.

Does anybody got this working and can you provide an example?

Which library are you using to generate the barcode?

We are using pyBarcode without problems. Here is the relevant code:



import barcode
from barcode.writer import ImageWriter


class Product:

barcode = fields.Function(fields.Binary("Barcode", states={ 'invisible': ~Eval('barcode'), }),
        'get_barcode')



def get_barcode(self, name): fd = BytesIO() barcode.generate( 'ean13', self.code[:12].zfill(12), writer=ImageWriter(), output=fd) fd.seek(0)
        return fields.Binary.cast(fd.read())


This should show without problems on the report.

[1] https://pypi.python.org/pypi/pyBarcode/0.8b1


--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

--
You received this message because you are subscribed to the Google Groups 
"tryton-dev" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton-dev/5564e07f-eb82-9297-8c9e-f8a502e3b4d2%40koolpi.com.

Reply via email to