0

i'm converting this piece of XML string into a 2D barcode using TCPDF/Datamatrix. This is my string:

<AN14>G6Y0A3</AN14>

This is how i'm trying to generate the barcode:

$pdf->write2DBarcode('<AN14>G6Y0A3</AN14>', 'DATAMATRIX', 124, 189, 66, 66, $some_defined_style, 'N');

PDF is generated correctly, however when i scan it, i get:

[)>06<AN14>G6Y7O2<D;GS9>A03

If i insert a whitespace in the middle of G6Y0A3 string resulting G6Y 0A3, i get a correct scan output.

I found out the issue is generated in this file: tcpdf/include/barcodes/datamatrix.php, specifically within this getHighLevelEncoding() function, however that's a way too low level programming for me.

Is this a bug? Am i doing something wrong? Maybe i'm missing to encode my xml string before sending it through write2DBarcode() function?

Thanks in advance.

Eduardo Escobar
  • 3,301
  • 2
  • 18
  • 15

1 Answers1

0

I came up with a similar problem. After reporting to Git TCPDF, I was denied access there. They have a bug in the code for generating datamatrix.

  • Please use the comments section if you are not able to provide a real solution. – Danilo Körber Mar 31 '22 at 06:18
  • Hey Jaroslav, turned out their library does not handle very well some utf-8 strings. I had to dig into the library files and change some `ord()` functions by `mb_ord()` (i can't recall where exactly, though). – Eduardo Escobar Jul 02 '22 at 00:15