diff --git a/assets/uploads/vouchers/6a0f569864c5a-Screenshot_356.png b/assets/uploads/vouchers/6a0f569864c5a-Screenshot_356.png
new file mode 100644
index 00000000..9bf0941d
Binary files /dev/null and b/assets/uploads/vouchers/6a0f569864c5a-Screenshot_356.png differ
diff --git a/imprimir_etiquetas_termica.php b/imprimir_etiquetas_termica.php
index 47611fd0..6d6a497e 100644
--- a/imprimir_etiquetas_termica.php
+++ b/imprimir_etiquetas_termica.php
@@ -66,7 +66,7 @@ if (empty($codes)) {
align-items: center;
overflow: hidden;
text-align: center;
- padding: 1mm;
+ padding: 3mm 1mm 1mm 1mm; /* Aumentado padding superior de 1mm a 3mm para bajar el contenido */
border: 0.1mm solid #eee; /* Guía visual en pantalla */
}
@@ -83,20 +83,22 @@ if (empty($codes)) {
}
.barcode-container {
- height: 9.12mm; /* Altura exacta solicitada */
+ height: 9mm; /* Reducido de 11mm a 9mm */
display: flex;
justify-content: center;
align-items: center;
margin: 1mm 0; /* Margen vertical */
- padding: 0 2mm; /* Margen lateral de 2mm solicitado */
+ padding: 0 1mm; /* Reducido de 2mm a 1mm para maximizar grosor de barras */
box-sizing: border-box;
width: 100%; /* Ocupa el ancho de la etiqueta para centrar */
}
.barcode-container svg {
- height: 9.12mm;
- width: auto; /* Que el ancho sea proporcional a la cantidad de caracteres */
+ height: 9mm;
+ width: auto;
shape-rendering: crispEdges;
+ display: block;
+ margin: 0 auto;
}
.sku-text {
@@ -150,9 +152,10 @@ if (empty($codes)) {
getBarcode($code, 1, 70);
+ // widthFactor 1.2 + altura 72 en el SVG, escalado a 9mm en CSS
+ // resulta en una barra mínima de ~0.15mm (9 / 72 * 1.2)
+ // Esto reduce la densidad y mejora la lectura sin ser demasiado grueso.
+ echo $generator->getBarcode($code, 1.2, 72);
?>
diff --git a/includes/barcode_generator.php b/includes/barcode_generator.php
index 156c486c..cee34e57 100644
--- a/includes/barcode_generator.php
+++ b/includes/barcode_generator.php
@@ -11,23 +11,27 @@ class BarcodeGenerator
$this->barcode_codes = $this->getCode128Map();
}
- public function getBarcode($code, $widthFactor = 2, $height = 50, $foregroundColor = 'black')
+ public function getBarcode($code, $widthFactor = 1, $height = 50, $foregroundColor = 'black')
{
$barcodeData = $this->getBarcodeData($code);
+ if (!$barcodeData) return '';
$bars = '';
- $x = 0;
+ $quietZone = 10; // 10 modules of quiet zone
+ $x = $quietZone;
- // Generate SVG bars
- foreach (str_split($barcodeData['bars']) as $bar) {
- $width = $widthFactor * (int)$bar;
- if ($x % 2 == 0) { // 0, 2, 4... are black bars
+ $barArray = str_split($barcodeData['bars']);
+ for ($i = 0; $i < count($barArray); $i++) {
+ $width = $widthFactor * (int)$barArray[$i];
+ if ($i % 2 == 0) { // Even indices are bars, odd are spaces
$bars .= '';
}
$x += $width;
}
- $svg = '