@php @include('tcpdf/tcpdf.php'); // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, 'px', PDF_PAGE_FORMAT, true, 'UTF-8', false); // set header and footer fonts $pdf->setHeaderFont([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]); $pdf->setFooterFont([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); // set auto page breaks $pdf->SetAutoPageBreak(false, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) { require_once dirname(__FILE__) . '/lang/eng.php'; $pdf->setLanguageArray($l); } // --------------------------------------------------------- // set font // $pdf->SetMargins(40, 1, 40); $pdf->SetFont('helveticaB', 'B', 22); $pdf->SetFillColor(255, 255, 255); // add a page $pdf->AddPage('P'); $pdf->SetMargins(42, 0, 10); $y = 40; $x = 60; $invoice_image = 'storage/'.$binvoice; $pdf->Image($invoice_image, 0, 0, 595, 842, '', '', 'T', false, 300, '', false, false, 0, false, false, false); $pdf->SetFont('freeserif', 'B', 10); $pdf->SetTextColor(0, 0, 0); $pdf->MultiCell(300, 10,"".$bname, 0, 'L', true, 1, '40', '50', true, 0, false, true, 0, 'T', false); $pdf->MultiCell(300, 10,"".$bname_ps, 0, 'L', true, 1, '40', '60', true, 0, false, true, 0, 'T', false); $pdf->MultiCell(300, 10,"".$bphone, 0, 'L', true, 1, '40', '80', true, 0, false, true, 0, 'T', false); $pdf->MultiCell(300, 10,"".$bemail, 0, 'L', true, 1, '40', '90', true, 0, false, true, 0, 'T', false); $pdf->SetFont('freeserif', 'B', 10); $pdf->SetTextColor(0, 0, 0); $pdf->MultiCell(150, 10,"".$bill->invoice_number, 0, 'L', true, 1, '500', '145', true, 0, false, true, 0, 'T', false); $pdf->MultiCell(150, 10,"".$bill->invoice_date, 0, 'L', true, 1, '500', '167', true, 0, false, true, 0, 'T', false); $pdf->SetFont('freeserif', 'B', 10); $pdf->SetTextColor(0, 0, 0); $pdf->MultiCell(150, 10, $bill->customer_name, 0, 'C', true, 1, '60', '135', true, 0, false, true, 0, 'T', false); $pdf->MultiCell(150, 10, $bill->customer_phone, 0, 'C', true, 1, '60', '145', true, 0, false, true, 0, 'T', false); $pdf->MultiCell(150, 10, $bill->customer_email, 0, 'C', true, 1, '71', '140', true, 0, false, true, 0, 'T', false); $pdf->SetFont('freeserif', '', 9); $pdf->SetTextColor(0, 0, 0); $pdf->Ln(61); $i=1; foreach ($bill_items as $row) { if($bill->type_id==1){ $qty=$row->qty; $item=$row->category->title_en."/ ".$row->sub_category->title_en."/ ".$row->unit->title_en; $price=$row->sale_price; $total=$row->total; }else{ $qty=$row->qty; $item=$row->name; $price=$row->price; $total=$row->total; } $pdf->Cell(75,10,$i,1,0,'C',false); $pdf->Cell(185,10,$item,1,0,'C',false); $pdf->Cell(60,10,$qty,1,0,'C',false); $pdf->Cell(93,10,$price,1,0,'C',false); $pdf->Cell(115,10,$total,1,1,'C',false); $i++; if($i == 11){ $pdf->SetAutoPageBreak(true, 50); } else{ $pdf->SetAutoPageBreak(true, 70); } } $pdf->SetFont('freeserif', '', 10); $pdf->SetTextColor(0, 0, 0); $pdf->MultiCell(150, 10, $bill->final_amount." ".$bill->currency->title_en, 0, 'L', true, 1, '510', '696', true, 0, false, true, 0, 'T', false); $pdf->MultiCell(150, 10, $bill->received." ".$bill->currency->title_en, 0, 'L', true, 1, '510', '707', true, 0, false, true, 0, 'T', false); $pdf->MultiCell(150, 10, $bill->balance." ".$bill->currency->title_en, 0, 'L', true, 1, '510', '717', true, 0, false, true, 0, 'T', false); // $pdf->MultiCell(150, 10, $dev_amount." ".$bill->currency->title_en, 0, 'L', true, 1, '510', '730', true, 0, false, true, 0, 'T', false); // $pdf->MultiCell(150, 10, $t_balance." ".$bill->currency->title_en, 0, 'L', true, 1, '510', '741', true, 0, false, true, 0, 'T', false); $pdf->SetTextColor(0, 0, 0); $style = [ 'position' => '', 'align' => 'C', 'stretch' => false, 'fitwidth' => true, 'cellfitalign' => '', 'border' => false, 'vpadding' => 'auto', 'hpadding' => 'auto', 'fgcolor' => [0, 0, 0], 'bgcolor' => false, //array(255,255,255) 'module_width' => 1, // width of a single module in points 'module_height' => 1, // height of a single module in points ]; $barcode =""; // $pdf->write1DBarcode($barcode, 'C39', '390','480','',40,0.7, $style, 'N'); // $pdf->MultiCell(110, 10, 'Reg '.'Registeration Number', 0, 'C', true, 1, '395', '520', true, 0, false, true, 0, 'T', false); $pdf->write2DBarcode($barcode, 'QRCODE,H', 200, 60, 80, 80, $style, 'N'); // $pdf->write2DBarcode('Qrcode', 'QRCODE,H', 80, 60, 0, 0, $style, 'N'); // --------------------------------------------------------- // footer information $pdf->SetFont('freeserif', '', 10); $pdf->SetTextColor(0, 0, 0); $pdf->MultiCell(300, 10,"( ".$baddress." )", 0, 'L', true, 1, '90', '774', true, 0, false, true, 0, 'T', false); $pdf->Output($bname.'-'.$bill->id.'.pdf', 'I'); exit(); @endphp