Como mencionaba el amigo anteriormente, FPF, es una excelente opcion, sencillo, gratis, pero eficaz, de hecho yo lo utilizo para la creación de reportes, y podrías crear el pdf cada vez que quieras imprimir un boleto, eso no tiene mayor complicacion pues para la creación del mismo utilizas siempre el mismo algoritmo y solo modificas la consulta sql y listo. Te envio un ejemplo de la creacion de un reporte en php. Solo tienes que modificarlo para tus requerimientos ya que este es una hoja tamaño carta y una bd especifica. Espero te sirva de algo
<?php
require('fpdf/fpdf.php');
require('conexion.php');
class PDF extends FPDF
{
var $widths;
var $aligns;
function SetWidths($w)
{
//Set the array of column widths
$this->widths=$w;
}
function SetAligns($a)
{
//Set the array of column alignments
$this->aligns=$a;
}
function Row($data)
{
//Calculate the height of the row
$nb=0;
for($i=0;$i<count($data);$i++)
$nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
$h=4*$nb;
//Issue a page break first if needed
$this->CheckPageBreak($h);
//Draw the cells of the row
for($i=0;$i<count($data);$i++)
{
$w=$this->widths[$i];
$a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
//Save the current position
$x=$this->GetX();
$y=$this->GetY();
//Draw the border
//$this->Rect($x,$y,$w,$h);
//Print the text
$this->MultiCell($w,4,$data[$i],0,$a);
//Put the position to the right of the cell
$this->SetXY($x+$w,$y);
}
//Go to the next line
$this->Ln($h);
}
function CheckPageBreak($h)
{
//If the height h would cause an overflow, add a new page immediately
if($this->GetY()+$h>$this->PageBreakTrigger)
$this->AddPage($this->CurOrientation);
}
function NbLines($w,$txt)
{
//Computes the number of lines a MultiCell of width w will take
$cw=&$this->CurrentFont['cw'];
if($w==0)
$w=$this->w-$this->rMargin-$this->x;
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
$s=str_replace("\r",'',$txt);
$nb=strlen($s);
if($nb>0 and $s[$nb-1]=="\n")
$nb--;
$sep=-1;
$i=0;
$j=0;
$l=0;
$nl=1;
while($i<$nb)
{
$c=$s[$i];
if($c=="\n")
{
$i++;
$sep=-1;
$j=$i;
$l=0;
$nl++;
continue;
}
if($c==' ')
$sep=$i;
$l+=$cw[$c];
if($l>$wmax)
{
if($sep==-1)
{
if($i==$j)
$i++;
}
else
$i=$sep+1;
$sep=-1;
$j=$i;
$l=0;
$nl++;
}
else
$i++;
}
return $nl;
}
function Header()
{
$this->SetFont('Arial','',25);
$this->Text(70,20,'Souvenir My Beach',0,'C', 0);
$this->SetFont('Arial','',15);
$this->Text(20,35,'CIERRE DE CAJA DETALLADO',0,'C', 0);
$this->Ln(25);
}
function Footer()
{
$this->SetY(-15);
$this->SetFont('Arial','B',8);
$this->Cell(100,10,'Creado por Roberto Guerrero / Tel.: (506)8749-3842. /
[email protected]',0,0,'L');
}
}
$fecha=time()-21600;
if (isset($_POST['hoy']))
{
$fechai=date("Y-m-d",$fecha);
}
else
{
$fechai=$_POST['year']."-".$_POST['mes']."-".$_POST['dia'];
}
if (isset($_POST['quickr']))
{
if ($_POST['quickr']==2)
{
$fechai=date("Y-m-d",$fecha-86400);
}
if ($_POST['quickr']==3)
{
$fechai=date("Y-m-d",$fecha-172800);
}
if ($_POST['quickr']==4)
{
$fechai=date("Y-m-d",$fecha-259200);
}
}
//$product= $_POST['codigo'];
$con = new DB;
$products = $con->conectar();
//$strConsulta = "SELECT * from products WHERE code = '$product'";
//$products = mysql_query($strConsulta);
//$fila = mysql_fetch_array($products);
$pdf=new PDF('P','mm','Letter');
$pdf->Open();
$pdf->AddPage();
$pdf->SetMargins(15,15,15);
$pdf->Ln(10);
$pdf->SetFont('Arial','',12);
$pdf->Cell(0,6,'Fecha: '.$fechai,0,1);
$pdf->Ln(10);
$pdf->SetFont('Arial','',10);
$pdf->SetWidths(array(20, 13, 15, 60, 15, 15, 25, 20));
$pdf->SetAligns(array('C','C','C','L',0,0,0,0));
$pdf->Row(array("HORA","FAC","COD","PRODUCTO","CANT","% DSC","MONTO","TC"));
$listado = $con->conectar();
$strConsulta = "SELECT transactions.time, transactionitems.transaction_id, transactionitems.product_id, transactions.date,
products.name, transactionitems.qty, transactions.disc, transactionitems.price, transactions.paymethod, transactions.amount
FROM transactionitems
Inner Join transactions ON transactionitems.transaction_id = transactions.id
Inner Join products ON transactionitems.product_id = products.code
WHERE transactions.date = '$fechai'";
$queryventas = mysql_query($strConsulta);
$numfilas = mysql_num_rows($queryventas);
$totalcash=0;
$totalfila=0;
$totaltarjeta=0;
$pdf->Cell(0,6,'','T',1);
for ($i=0; $i<$numfilas; $i++)
{
$fila = mysql_fetch_array($queryventas);
$tarjeta="";
if($fila['paymethod']=="2"){$tarjeta="*".'$'.$fila['amount'];}
if($fila['transaction_id']==465){$fila['disc']=0;}
$totalfila=$fila['price']*$fila['qty']-
(($fila['price']*$fila['qty']/100)*$fila['disc']);
if($fila['transaction_id']==465){$totalfila=10;}
$pdf->Row(array($fila['time'],$fila['transaction_id'],$fila['product_id'],
$fila['name'],$fila['qty'],$fila['disc'],number_format($totalfila,2),$tarjeta));
if($fila['paymethod']=="2"){$totaltarjeta=$totaltarjeta+$totalfila;}
else{$totalcash=$totalcash+$totalfila;}
//number_format($totalfila,2);
}
//$pdf->Cell(0,0,"number_format($totalfila,2)",0,0,'R',fa lse);
$pdf->Cell(0,6,'',0,1);
$pdf->SetFont('Arial','',10);
$pdf->SetX(150);
$pdf->Cell(40,8,'TOTAL TC : $ '.number_format($totaltarjeta,2),0,1,'R');
$pdf->SetX(140);
$pdf->Cell(50,8,'TOTAL EFECTIVO: $ '.number_format($totalcash,2),'B',1,'R');
$pdf->SetX(130);
$pdf->SetFont('Arial','',12);
$pdf->Cell(60,10,'TOTAL VENDIDO : $ '.number_format($totalcash+$totaltarjeta,2),0,1,'R ');
$pdf->Output();
?>