Edinburgh-Genome-Foundry / blabel

:label: Python label/sticker PDF generation. HTML templates, built-in barcodes, qr codes, and other goodies
https://edinburgh-genome-foundry.github.io/blabel
MIT License
179 stars 38 forks source link

Too long text is silently discarded #2

Open hlovdal opened 4 years ago

hlovdal commented 4 years ago

With a template like

<img src="{{label_tools.qr_code(label_id)}}"/>
<span class='label'>{{ label_text }}</span>

css style like in README.rst and records like

records= [
...
    dict(label_id="112", label_text="123456789012"),
    dict(label_id="113", label_text="1234567890123"),
    dict(label_id="114", label_text="12345678901234"),
    dict(label_id="115", label_text="123456789012345"),
    dict(label_id="116", label_text="1234567890123456"),
    dict(label_id="117", label_text="12345678901234567"),
    dict(label_id="118", label_text="123456789012345678"),
...

all labels after "12345678901234" only contains the QR code while the text is blank.

One thing is not handling auto-scaling or word splitting, but silently dropping input is really bad. Could you please fix to at least give a warning/error?

Zulko commented 4 years ago

Can you provide a full example, with HTML, CSS and python? I suspect that the issue here is not "dropping input" but a formatting issue: when the label is too long, it gets printed on a new line that falls outside of the printed area of the label. This could be partially fixed by CSS, using either text-overflow: ellipsis; or word-break: always;.

W-M-D commented 4 years ago

I too am having this issue. I'm re writing a script with your library. I need to resize the text so it fits the label. No idea how to do it with css. Have tried multiple ways :/ .

Zulko commented 4 years ago

You could decide the font size (or even the page size) based on the label length, on the python side, since the template uses Jinja.