0
Well, my problem is this::
I have the digit line and I want to turn it into barcode.
You must be thinking: "our this is quite simple using some ready classes you have on the web!".
Yes, I have tested several models and when reading the generated barcode is interpreted with other numbers. At first it looks the same, but in certain parts of the code it changes, but I have no idea why.
Anyone who can help me, I would be very grateful. I really need to solve this problem.
EXAMPLE:
Digitable line for conversion:
846100000005919402962014711150030007003147180834
What is generating:
846100000005591940296203147111500301007003147183
<?php
function geraCodigoBarra($numero){
$fino = 1;
$largo = 3;
$altura = 50;
$barcodes[0] = '00110';
$barcodes[1] = '10001';
$barcodes[2] = '01001';
$barcodes[3] = '11000';
$barcodes[4] = '00101';
$barcodes[5] = '10100';
$barcodes[6] = '01100';
$barcodes[7] = '00011';
$barcodes[8] = '10010';
$barcodes[9] = '01010';
for($f1 = 9; $f1 >= 0; $f1--){
for($f2 = 9; $f2 >= 0; $f2--){
$f = ($f1*10)+$f2;
$texto = '';
for($i = 1; $i < 6; $i++){
$texto .= substr($barcodes[$f1], ($i-1), 1).substr($barcodes[$f2] ,($i-1), 1);
}
$barcodes[$f] = $texto;
}
}
echo '<img src="imagens/p.gif" width="'.$fino.'" height="'.$altura.'" border="0" />';
echo '<img src="imagens/b.gif" width="'.$fino.'" height="'.$altura.'" border="0" />';
echo '<img src="imagens/p.gif" width="'.$fino.'" height="'.$altura.'" border="0" />';
echo '<img src="imagens/b.gif" width="'.$fino.'" height="'.$altura.'" border="0" />';
echo '<img ';
$texto = $numero;
if((strlen($texto) % 2) <> 0){
$texto = '0'.$texto;
}
while(strlen($texto) > 0){
$i = round(substr($texto, 0, 2));
$texto = substr($texto, strlen($texto)-(strlen($texto)-2), (strlen($texto)-2));
if(isset($barcodes[$i])){
$f = $barcodes[$i];
}
for($i = 1; $i < 11; $i+=2){
if(substr($f, ($i-1), 1) == '0'){
$f1 = $fino ;
}else{
$f1 = $largo ;
}
echo 'src="imagens/p.gif" width="'.$f1.'" height="'.$altura.'" border="0">';
echo '<img ';
if(substr($f, $i, 1) == '0'){
$f2 = $fino ;
}else{
$f2 = $largo ;
}
echo 'src="imagens/b.gif" width="'.$f2.'" height="'.$altura.'" border="0">';
echo '<img ';
}
}
echo 'src="imagens/p.gif" width="'.$largo.'" height="'.$altura.'" border="0" />';
echo '<img src="imagens/b.gif" width="'.$fino.'" height="'.$altura.'" border="0" />';
echo '<img src="imagens/p.gif" width="1" height="'.$altura.'" border="0" />';
}
geraCodigoBarra('846100000005919402962014711150030007003147180834');
?>
How do you return this in numbers instead of images?
– Sam
I’m sorry, but I don’t understand your question. For what returns is this number : 846100000005591940296203147111500301007003147183
– Lucas Pires
When playing your code, returns a code bar in images. I would like to see the number for this bar.
– Sam
Yes friend, this is the same one I put... when the reader reads the barcode, he reads and shows me this number: 846100000005591940296203147111500301007003147183
– Lucas Pires
I understand, but how do you return this number without a reader?
– Sam
This number I obtained through a reader, and also has a website that converts the digitable line into barcode and already shows the numbers that represent the generated barcode. What I can not understand is that I ask to generate on top of a digital line... and ends up turning into another.... Site mentioned: https://www.free-barcode-generator.net/2of5-interleaved/
– Lucas Pires
I tested the code generated in the phone reader and returned the same number.
– Sam
Your reader must be defective. I read it on the phone and returned the same number. I read it on a website that reads Cód. online bar and returned the same number: https://i.stack.Imgur.com/dVg1R.jpg
– Sam
our serious...? you asked to generate the barcode for this number: 846100000005919402962014711150030007003147180834 ? can send a picture of the kindly generated barcode.
– Lucas Pires
It’s in the image link of my last comment.
– Sam
I read your image and returned another number... 846100000005591940296203147111500301007003147183 In the same way that is happening in my application,
– Lucas Pires
Test in another barcode, of some packaging there to see if returns the same number.
– Sam
So this barcode I Gero to perform payment... will be part of a billet, so when I’m trying to perform reading, I’m doing it by the bank app, I’m telling you this because I tested it with a barcode reader app, and it actually reads the right number, but in the bank app, the mentioned problem is happening.
– Lucas Pires
Yeah, when he does the reading, he turns into that different number I posted.
– Lucas Pires