The EAN13 bacode ignores the format selection, always uses SVG format

Created on 22 January 2025, 3 months ago

Problem/Motivation

EAN13 code ignores the selected format; the template for that format forces SVG format unlike any other template:

<div class="code">{{ svg|raw }}</div>

Steps to reproduce

Create a barcode field, select the EAN13 barcode formatter, select any format except the SVG. Check the resulting image, it will always use the SVG format.

Proposed resolution

update the code to use the same variable as other templates:
<div class="code">{{ barcode|raw }}</div>

Or have a comment somewhere explaining why the SVG is forced.

πŸ› Bug report
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine artem_sylchuk Lutsk

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @artem_sylchuk
  • Pipeline finished with Success
    3 months ago
    Total: 289s
    #403174
  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    It seems the EAN13 template was changed in #3022641: EAN13 extended code not shown β†’ .
    I don't know why that change was made because that change was not mentioned in the issue.
    That issue was about printing the extended code correctly, when the barcode value is shown. Can you check on your site to make sure that the extended value displays correctly when you change svg to barcode in the template?

    Thank you for finding this.

  • πŸ‡ΊπŸ‡¦Ukraine artem_sylchuk Lutsk

    I tested different formats. SVG and PNG look fine, however, other formats don't.

    The HTML div format can be fixed by adding the
    .barcode-ean13 .value {position:relative}

    And for "binary string" and "Unicode string" it may not make sense to output the code value.
    Probably, we should have a note about that on the formatter settings.

    Also, #3022641: EAN13 extended code not shown β†’ didn't change the output format to SVG in the template, it looks like it was that way from the very beginning, the other templates were updated in #3025572: Image barcode β†’ but not the EAN-13 for some reason.

    Another note is that the code value still doesn't look perfect, even for the SVG, it requires CSS adjustments for different code dimensions.
    I've tried to put the code over an image using PHP but it also requires a lot of work for proper positioning, plus it depends on fonts installed on the system so I gave up the idea and switched to bwip-js instead for my project.

    Working on it as part of #LutskGCW25

  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    Yes, the text output is not very good - it just adds an HTML element holding the barcode value. While it can be styled to line up with the bar values and aligned with the code itself, that requires a lot of work.

    It is definitely something that should be put into this module, but that's a different issue entirely! And will require a good amount of work for a general solution, as this is not something provided by the underlying tecnickcom/tc-lib-barcode library. I honestly don't think many people use/need the text value, since there haven't been any issues opened about this in the past. It would be nice to have some contribution from the community here, from some people who need/want this feature to work better. I personally don't need that, so it's going to be a low priority for me.

    So I'm just committing your fix, which will fix the original issue, then I will write up a separate issue for the work that I think should be done on the text output.

  • Pipeline finished with Skipped
    2 months ago
    #416323
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024