OkapiBarcode icon indicating copy to clipboard operation
OkapiBarcode copied to clipboard

EANX barcode offsetX is not correct

Open anyonetff opened this issue 1 year ago • 2 comments

data = 123456789012

create the EAN13 svg

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
   "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="95" height="70" version="1.1" xmlns="http://www.w3.org/2000/svg">
   <desc>123456789012</desc>
   <g id="barcode" fill="#000000">
      <rect x="0" y="0" width="95" height="70" fill="#FFFFFF" />
      <!-- ERROR -->
      <!-- the first rect starts form x=0, there is no space for the first character -->
      <rect x="0.00" y="0.00" width="1.00" height="65.00" />
      <rect x="2.00" y="0.00" width="1.00" height="65.00" />
      <rect x="5.00" y="0.00" width="1.00" height="60.00" />
      <rect x="8.00" y="0.00" width="2.00" height="60.00" />
      <rect x="11.00" y="0.00" width="4.00" height="60.00" />
      <rect x="16.00" y="0.00" width="1.00" height="60.00" />
      <rect x="19.00" y="0.00" width="3.00" height="60.00" />
      <rect x="23.00" y="0.00" width="1.00" height="60.00" />
      <rect x="25.00" y="0.00" width="2.00" height="60.00" />
      <rect x="30.00" y="0.00" width="1.00" height="60.00" />
      <rect x="35.00" y="0.00" width="1.00" height="60.00" />
      <rect x="37.00" y="0.00" width="1.00" height="60.00" />
      <rect x="40.00" y="0.00" width="1.00" height="60.00" />
      <rect x="44.00" y="0.00" width="1.00" height="60.00" />
      <rect x="46.00" y="0.00" width="1.00" height="65.00" />
      <rect x="48.00" y="0.00" width="1.00" height="65.00" />
      <rect x="50.00" y="0.00" width="1.00" height="60.00" />
      <rect x="53.00" y="0.00" width="1.00" height="60.00" />
      <rect x="57.00" y="0.00" width="3.00" height="60.00" />
      <rect x="61.00" y="0.00" width="1.00" height="60.00" />
      <rect x="64.00" y="0.00" width="3.00" height="60.00" />
      <rect x="69.00" y="0.00" width="1.00" height="60.00" />
      <rect x="71.00" y="0.00" width="2.00" height="60.00" />
      <rect x="75.00" y="0.00" width="2.00" height="60.00" />
      <rect x="78.00" y="0.00" width="2.00" height="60.00" />
      <rect x="81.00" y="0.00" width="2.00" height="60.00" />
      <rect x="85.00" y="0.00" width="1.00" height="60.00" />
      <rect x="88.00" y="0.00" width="1.00" height="60.00" />
      <rect x="92.00" y="0.00" width="1.00" height="65.00" />
      <rect x="94.00" y="0.00" width="1.00" height="65.00" />
      <!-- ERROR -->
      <!-- the first character is starts form x=-5. it's out of the canvas -->
      <text x="-5.00" y="68.00" text-anchor="end"
         font-family="Helvetica" font-size="8.00" fill="#000000">
         1
      </text>
      <text x="5.00" y="68.00" text-anchor="start"
         textLength="39.00" lengthAdjust="spacing"
         font-family="Helvetica" font-size="8.00" fill="#000000">
         234567
      </text>
      <text x="51.00" y="68.00" text-anchor="start"
         textLength="39.00" lengthAdjust="spacing"
         font-family="Helvetica" font-size="8.00" fill="#000000">
         890128
      </text>
   </g>
</svg>

the coord of every rect and text should fixed with x += some offsetX (maybe x = x + 9) after setContent(ean13 data) the first TextBox x value in the Symbol object is -9

anyonetff avatar Sep 09 '24 09:09 anyonetff

You'll want to use setQuietZoneHorizontal(int) to add enough horizontal space to fit the prefix digit.

It may be a good idea to document this in the JavaDoc, and/or perhaps add some default horizontal quiet zone to EAN and UPC symbols. I'll keep this bug open as a reminder to look into this.

gredler avatar Sep 10 '24 12:09 gredler

I found the method to fix the problem. but the Settings.java do not support the -w --whitesp parameter The zint-qt whitesp support x & y two dimensions, as the zint commad line set both of x & y.

anyonetff avatar Sep 11 '24 10:09 anyonetff

Are you using Okapi via the command line, or are you using it as a Java library in your own Java code?

gredler avatar Oct 02 '24 16:10 gredler

No feedback, closing for now. Feel free to re-open with additional information.

gredler avatar Jan 20 '25 18:01 gredler