#10 EAN 128 support

closed-fixed
nobody
None
5
2014-08-31
2005-05-25
birch
No

Hi everybody, here is my announced EAN128 support

I didn't have time to write a proper documentation, so
here is a crashcourse:

Advice: try this patch the demo applet!

Description of XML-Format:
<barcode>
<code128>
<template>{string:}</template>
<group-separator>{string:&#xF1;}</group-separator>

<check-digit-marker>{string:&#xF0;}</check-digit-marker>
<height>{length:15mm}</height>
<module-width>{length:0.21mm}</module-width>
<quiet-zone
enabled="{boolean:true}">{length:10mw}</quiet-zone>
<human-readable>
<omit-brackets>{boolean:false}</omit-brackets>

<placement>{human-readable-placement:bottom}</placement>
<font-name>{font-name:Helvetica}</font-name>
<font-size>{length:8pt}</font-size>
</human-readable>
</code128>
</barcode>

Notes:

If you want to encode multiple Application Identifiers
(AI) you usually have to show where one AI ends and the
next one starts. The char that separates the AIs can be
specified by <group-separator>
In this implementation you can ALWAYS use the
<group-separator> between two AIs, even if
EAN128-standard does not allow a FNC1 (so you do not
need to understand the EAN128 details).
The rules for usage of FNC1 are misunderstood very
often (I hope I got it right, discussion welcome):
If the AI starts with chars
"00" - "04", "1", "20", "23", "31" - "36" or "41"
you are not allowed to use an FNC1 in front of the next
AI. In every other case you MUST use one!

My intend was to use ASCII-Code "GS" aka
ASCII-Group-Separator aka x1D for <group-separator>.
Most EAN-128-capable barcode scanners deliver this sign
if they read an FNC1! So a lot of EAN128 users do not
know what FNC1 is. Unfortunately I could not use "GS"
in fop. Chars below 32 seem to cause trouble. So I
default to xF1.

<check-digit-marker>
If really love the feature <checksum>auto</checksum> in
barcode4j (eg in ean-13) so I want to keep it.
Unfortunately in EAN128 this is more difficult. Lets
have a look at AI (8003). It contains 13 digits (n13)
followed by the check digit (cd) followed by 1 to 16
chars (n13+cd+an1-16).
So i introduced a special character
<check-digit-marker> that will always be replaced by a
check digit if it is found at a proper place.
(Fortunately in most cases you even can omit the
<check-digit-marker>: eg AIs (00), (01), (02),
(410)-(415) and if you want to (91) USPS Confirmation
Service.

<template>
In my first version all the EAN128 AIs had been
hardcoded. The code was small, readable and in the
spirit of object orientation. Then I needed new AIs.
Late I did some research and found some more. After
that I found even more and more and more... So I
decided to make everything configurable. I apologize
for the state of my code.

The idea is to define which AIs you want to use and how
they look like:
eg: <template>(01)n13+cd(421)n3+an1-9(10)an1-20</template>
allowed data types are numeric (n), alpha-numeric (an),
date (d) followed by a fixed or variable length
A check-digit (cd) has always a length of one. (cd0
means check-digit calculation includes the AI!
Greetings from the USPS) AIs can consist of several
Parts indicated by '+'-Signs.

Most AIs I found are already defined in
org.krysalis.barcode4j.impl.code128.EAN128AI.properties.
You do not need an <template> for them.
Some are not include because they are country specific
(like (91)-USPS Confirmation Service) or mutually
agreed between trading partners (90).

<omit-brackets>true<omit-brackets> does not show the
AI-brackets.

example
<msg>42012345&#xF1;910112345678912345678&#xF0;</msg>
<ean128>
<quiet-zone>1cm</quiet-zone>

<template>(420)n5(91)n2+n9+n2-8+cd0</template>
<group-separator>&#xF1;</group-separator>

<check-digit-marker>&#xF0;</check-digit-marker>
<human-readable>
<omit-brackets>true</omit-brackets>
</human-readable>
</ean128>

Known Bugs: Very often the human readable text is much
bigger than the barcode. This is not honored in
computation of size so the human readable text gets
truncated
workaround: increase the quiet-zone. Be aware that you
have to undo this as soon the bug is fixed.

Don't be surprised if I need some days to answer your
questions

Have fun,
Dietmar

Discussion

  • birch
    birch
    2005-05-25

    Patch file for EAN 128 support

     
    Attachments
  • Logged In: YES
    user_id=225352

    Hi Dietmar,

    thank you for your patch. At the moment, I don't have much
    free time to look at your work but I promise to review it as
    soon as possible. Looks like you've invested quite some time
    here. Thanks for your patience. You'll hear from me again
    later.

    Jeremias Maerki

     
  • Logged In: YES
    user_id=1500724

    Hi Dietmar, i've been trying to build a ean-128 barcode
    with fop after aplying this patch and now i got it.

    I just want to say that, in order to get it, i've had to do
    one more change that doesn't appear in your patch file. The
    change consist in adding a line to a fop java file.

    Index: src/fop-
    0.20.5/java/org/krysalis/barcode4j/fop0205/BarcodeElementMap
    ping.java
    ============================================================
    =======
    private static final String[] BARCODE_ELEMENTS =
    {"intl2of5", "code39", "codabar", "code128",
    "upc-a", "upc-e", "ean-13", "ean-8",
    "postnet",
    "height", "module-width", "wide-factor", "quiet-
    zone",
    "checksum", "human-readable",
    "human-readable-font", "human-readable-size",
    "font-name", "font-size", "placement",
    "display-start-stop", "display-checksum",
    "interchar-gap-width",
    "tall-bar-height", "short-bar-height", "baseline-
    alignment",
    + "ean128", "template", "group-separator", "check-
    digit-marker", "omit-brackets"
    };

    As you can see, all you have to do is to add the last line
    elements to the BARCODE_ELEMENTS variable.

     
    • status: open --> closed-fixed
     
  • Logged In: YES
    user_id=225352
    Originator: NO

    The EAN-128 stuff is applied and documented. Thanks a lot, Dietmar!