Código de Barras em PHP
Publicado por Guilherme Reschke 04/02/2008
[ Hits: 12.940 ]
Homepage: http://www.ee.pucrs.br/~reschke
Função para gerar código de barras. Simples de usar e código de fácil leitura.
function barcode($valor) { $code_txt = ""; $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; } } //Desenho da barra //Guarda inicial $code_txt = $code_txt . "\n<img src=./imgs/p.gif width=".$fino." height=".$altura." border=0><img\nsrc=./imgs/b.gif width=".$fino." height=".$altura." border=0><img\nsrc=./imgs/p.gif width=".$fino." height=".$altura." border=0><img\nsrc=./imgs/b.gif width=".$fino." height=".$altura." border=0><img\n"; $texto = $valor ; if(bcmod(strlen($texto),2) <> 0) { $texto = "0" . $texto; } // Draw dos dados while (strlen($texto) > 0) { $i = round(esquerda($texto,2)); $texto = direita($texto,strlen($texto)-2); $f = $barcodes[$i]; for($i=1;$i<11;$i+=2) { if (substr($f,($i-1),1) == "0") { $f1 = $fino ; } else { $f1 = $largo ; } $code_txt = $code_txt . " src=./imgs/p.gif width=".$f1." height=".$altura." border=0><img\n"; if (substr($f,$i,1) == "0") { $f2 = $fino ; } else { $f2 = $largo ; } $code_txt = $code_txt . " src=./imgs/b.gif width=".$f2." height=".$altura." border=0><img\n"; } } // Draw guarda final $code_txt = $code_txt . " src=./imgs/p.gif width=".$largo." height=".$altura." border=0><img\nsrc=./imgs/b.gif width=".$fino." height=".$altura." border=0><img\nsrc=./imgs/p.gif width=1 height=".$altura." border=0>\n"; return $code_txt; } //Fim da função function esquerda($entra,$comp) { return substr($entra,0,$comp); } function direita($entra,$comp) { return substr($entra,strlen($entra)-$comp,$comp); }
Converte um texto em seu respectivo codigo binario
Converter String para Maiúsculas
Script que efetua cálculos estatísticos
Criando um menu de paginação de resultados com algumas funcionalidades
Como aprovar Pull Requests em seu repositório Github via linha de comando
Como gerar um podcast a partir de um livro em PDF
Automatizando digitação de códigos 2FA no browser
Resolver problemas de Internet
Como compartilhar a tela do Ubuntu com uma Smart TV (LG, Samsung, etc.)
Como Definir o Painel Principal em Múltiplos Monitores no Linux Mint
Minecraft Launcher para Arch Linux
Instalar o Apache, MySQL e PHP no Oracle Linux 8
Resolvendo o erro "libQt6Widgets.so.6: cannot open shared object file" no Linux
Como bloquear e desbloquear papel de parede no Ubuntu 24.04 (0)
Mouse bluetooth no Debian 12.10. (0)
tentando instalar em um notebook antigo o Linux LegacyOS_2023... (2)