I have a code of my work that I must modify, that prints tickets in a printer epson of the fiscal type. I had no problems, until I need to add a poster only on some tickets, which I call a sign. Everything is printed on a PNG where I already have some predefined lines and it measures 1088px high. What I did was make 1200px the PNG and it happens to me that all the text of the ticket is compressed, whether it is a smaller pixel. I do not know much about the subject of printing but I would like to understand why it does ... My idea is to print the fonts in the size that I give them, that they do not shrink. I copy the function that prints:
<?php
function genero_tk($vjson)
{
global $vardir, $vardirdest, $vardirroot, $vardirlog, $file, $vdebug, $impresora;
$condi = "N";
$impresora = ($impresora = "ticketsdes") ? "Terminal 01" : "Terminal Desconocida";
$font = $vardir . 'arial.ttf';
$varsjson = json_decode($vjson);
if (!is_numeric($varsjson->{'ticket'})) {
extit;
}
$vnumticket = $varsjson->{'ticket'};
$vfecha = $varsjson->{'fecha'};
$vpremio = $varsjson->{'codpremio'};
$vdescpremio = $varsjson->{'descpremio'};
$vpuntos = $varsjson->{'puntos'};
$vnrosocio = $varsjson->{'nrosocio'};
$vnombre = $varsjson->{'nombre'};
$vapellido = $varsjson->{'apellido'};
$vdni = $varsjson->{'dni'};
$entero = explode(",", $vpuntos);
$puntos = $entero[0];
//leo el código de premio y consulto la leyenda2
$leyenda2 = file_get_contents("trlleyendas.php?p=" . $vpremio);
$leyenda2 = trim(strip_tags($leyenda2));
$condi = substr($leyenda2, -1);
$leyenda2 = substr($leyenda2, 0, -1);
$ticket = substr($vnumticket, -5);
//Fecha de Vencimiento
$fecha = date('Y-m-j');
$nuevafecha = strtotime('+30 day', strtotime($fecha));
$nuevafecha = date('j/m/Y', $nuevafecha);
setlocale(LC_TIME, 'es_CO.UTF-8');
//creo codigo de barras
barcode($vardir . "bc$vnumticket.png", $vnumticket, "100", "horizontal", "Code25", false, 2);
//Levanto el modelo de ticket
$dest = imagecreatefrompng($vardir . "ticket.png");
//Redimencionamos Barcode
$src = imagecreatefrompng($vardir . "bc$vnumticket.png");
$rot = imagecreatefrompng($vardir . "rotulo.png");
imagealphablending($dest, false);
imagesavealpha($dest, true);
$lines1 = explode('|', wordwrap($vdescpremio, 32, '|'));
$lines = explode('|', wordwrap($leyenda2, 44, '|'));
$x = 23;
$y = 200;
$int = 35;
imagettftext($dest, 19, 0, $x, $y, 0, $font, "Fecha: $vfecha");
$y += $int;
imagettftext($dest, 19, 0, $x, $y, 0, $font, "$puntos puntos");
$y += $int;
imagettftext($dest, 19, 0, $x, $y, 0, $font, "Socio nro.: $vnrosocio");
$y += $int;
imagettftext($dest, 19, 0, $x, $y, 0, $font, "$vapellido $vnombre");
$y += $int;
imagettftext($dest, 19, 0, $x, $y, 0, $font, "DNI: $vdni");
$y += $int;
imagettftext($dest, 19, 0, $x, $y, 0, $font, "Ticket: $ticket");
$y += $int;
imagettftext($dest, 19, 0, $x, $y, 0, $font, "Válido hasta el $nuevafecha");
$y += $int;
imagettftext($dest, 18, 0, $x, $y, 0, $font, " ");
$y += $int;
$y = $y - 10;
foreach ($lines1 as $line1) {
{
$line1 = trim($line1);
$bbox = imagettfbbox(25, 0, $font, $line1);
$x = $bbox[0] + (imagesx($dest) / 2) - ($bbox[4] / 2) - 25;
imagettftext($dest, 25, 0, $x, $y, 0, $font, $line1);
$y += $int;
}
}
imagettftext($dest, 16, 0, $x, $y, 0, $font, " ");
$y += $int;
foreach ($lines as $line) {
$line = trim($line);
$bbox = imagettfbbox(18, 0, $font, $line);
$x = $bbox[0] + (imagesx($dest) / 2) - ($bbox[4] / 2) - 25;
imagettftext($dest, 18, 0, $x, $y, 0, $font, $line);
$y += $int - 5;
}
$pie_ticket = trim("Gracias por utilizar nuestra $impresora");
imagettftext($dest, 18, 0, $x, $y, 0, $font, ".");
$y += $int;
$bbox = imagettfbbox(18, 0, $font, $pie_ticket);
$x = $bbox[0] + (imagesx($dest) / 2) - ($bbox[4] / 2) - 25;
imagettftext($dest, 18, 0, $x, 745, 0, $font, $pie_ticket);
imagettftext($dest, 18, 0, $x, $y, 0, $font, " ");
$y += $int;
imagettftext($dest, 18, 0, $x, $y, 0, $font, " ");
$y += $int;
imagettftext($dest, 18, 0, $x, $y, 0, $font, ".");
$y += $int;
imagettftext($dest, 18, 0, $x, $y, 0, $font, ".");
$y += $int;
imagecopymerge($dest, $src, ((imagesx($dest) - imagesx($src)) / 2) - 20, 770, 0, 0, imagesx($src), imagesy($src), 100);
if ($condi == "S") {
imagecopymerge($dest, $rot, ((imagesx($rot) - imagesx($src)) / 2) - 5, 910, 0, 0, imagesx($rot), imagesy($rot), 100);
}
imagettftext($dest, 17, 0, 130, 900, 0, $font, "$vnumticket");
$varchivopng = "$vnumticket-$file.png";
imagepng($dest, $vardirdest . $varchivopng);
//echo "La coordenada Y es : " . $y;
if ($vdebug) {
echo " guardo:$vardirdest$varchivopng";
}
imagedestroy($dest);
imagedestroy($src);
unlink($vardir . "bc$vnumticket.png");
rename($vardirroot . $file, $vardirlog . $vnumticket . $file);
if ($vdebug) {
echo " rename:$vardirroot$file/$vardirlog$vnumticket$file";
}
}