Ver Mensaje Individual
  #12 (permalink)  
Antiguo 06/10/2015, 14:37
Avatar de xfxstudios
xfxstudios
 
Fecha de Ingreso: junio-2015
Ubicación: Valencia - Venezuela
Mensajes: 2.448
Antigüedad: 8 años, 10 meses
Puntos: 263
Respuesta: imprimir etiqueta

con este codigo guardas las barras y las recuperas en la etiqueta:

Código PHP:
Ver original
  1. <?php
  2.  
  3. $prefijo = "abc";
  4. $cod = rand(1000,9999);
  5. $codigo = $cod."-".$prefijo;
  6.  
  7. // Including all required classes
  8. require_once('class/BCGFontFile.php');
  9. require_once('class/BCGColor.php');
  10. require_once('class/BCGDrawing.php');
  11.  
  12. // Including the barcode technology
  13. require_once('class/BCGcode39.barcode.php');
  14.  
  15. // Loading Font
  16. $font = new BCGFontFile('./font/Arial.ttf', 18);
  17.  
  18. // Don't forget to sanitize user inputs
  19. $text = isset($_GET['text']) ? $_GET['text'] : $codigo;
  20.  
  21. // The arguments are R, G, B for color.
  22. $color_black = new BCGColor(0, 0, 0);
  23. $color_white = new BCGColor(255, 255, 255);
  24.  
  25. $drawException = null;
  26. try {
  27.     $code = new BCGcode39();
  28.     $code->setScale(2); // Resolution
  29.     $code->setThickness(30); // Thickness
  30.     $code->setForegroundColor($color_black); // Color of bars
  31.     $code->setBackgroundColor($color_white); // Color of spaces
  32.     $code->setFont($font); // Font (or 0)
  33.     $code->parse($text); // Text
  34. } catch(Exception $exception) {
  35.     $drawException = $exception;
  36. }
  37.  
  38. /* Here is the list of the arguments
  39. 1 - Filename (empty : display on screen)
  40. 2 - Background color */
  41. $drawing = new BCGDrawing($codigo.'.png', $color_white);
  42. if($drawException) {
  43.     $drawing->drawException($drawException);
  44. } else {
  45.     $drawing->setBarcode($code);
  46.     $drawing->draw();
  47. }
  48.  
  49. // Header that says it is an image (remove it if you save the barcode to a file)
  50. /*header('Content-Type: image/png');
  51. header('Content-Disposition: inline; filename="barcode.png"');*/
  52.  
  53. // Draw (or save) the image into PNG format.
  54. $drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
  55. ?>
  56. <style>
  57. .etiqueta{
  58.     width:500px;
  59.     height:85px;
  60.     border:solid;
  61.     padding:10px;
  62.     background-color:#fff;
  63. }
  64. .col-6{
  65.     width:50%;
  66.     height:85px;
  67.     float:left;
  68.     position:relative;
  69. }
  70. .col-5{
  71.     width:30%;
  72.     height:85px;
  73.     float:left;
  74.     position:relative;
  75. }
  76. .col-6 img{
  77.     float:right;
  78.     margin-right:25px;
  79. }
  80. </style>
  81. <div class="etiqueta">
  82.     <div class="col-6">
  83.     Producto: <b>Nombre del Producto</b><br>
  84.     ID: del Producto: <b><?php echo $codigo; ?></b><br>
  85.     Fecha: <b><?php echo date("d-m-Y"); ?></b>
  86.     </div>
  87.     <div class="col-5">
  88.         <img src="<?php echo $codigo; ?>.png"/>
  89.     </div>
  90. </div>
__________________
[email protected]
HITCEL