@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(10, 0, 10); $y = 40; $x = 60; $invoice_image = 'storage/product_images/invoice-purchase.png'; $pdf->Image($invoice_image, 0, 0, 595, 842, '', '', 'T', false, 300, '', false, false, 0, false, false, false); $pdf->SetFont('freeserif', 'B', 12); $pdf->SetTextColor(102, 151, 255); $pdf->MultiCell(150, 10,"".$bill->invoice_number, 0, 'C', true, 1, '340', '238', true, 0, false, true, 0, 'T', false); $pdf->MultiCell(150, 10,"".$bill->invoice_date, 0, 'C', true, 1, '340', '258', true, 0, false, true, 0, 'T', false); $pdf->SetFont('freeserif', 'B', 10); $pdf->SetTextColor(0, 0, 0); $pdf->MultiCell(150, 10, $supplier->name, 0, 'C', true, 1, '310', '120', true, 0, false, true, 0, 'T', false); $pdf->MultiCell(150, 10, $supplier->address, 0, 'C', true, 1, '310', '130', true, 0, false, true, 0, 'T', false); $pdf->MultiCell(150, 10, $supplier->phone, 0, 'C', true, 1, '310', '140', true, 0, false, true, 0, 'T', false); $pdf->SetFont('freeserif', 'B', 9); $pdf->SetTextColor(0, 0, 0); $i = 1; $pdf->Ln(173); $i=1; foreach ($bill_items as $row) { $pdf->Cell(150,20,$row->qty,0,0,'C',false); $pdf->Cell(70,20,$row->category->title_en." ".$row->unit->title_en,0,0,'C',false); $pdf->Cell(260,20,$row->cpi,0,0,'C',false); $pdf->Cell(30,20,$row->total,0,1,'C',false); if($i == 11){ $pdf->SetAutoPageBreak(true, 50); } else{ $pdf->SetAutoPageBreak(true, 70); } $i++; } $pdf->SetFont('freeserif', 'B', 10); $pdf->SetTextColor(0, 0, 0); $pdf->MultiCell(150, 10, $bill->grand_total, 0, 'C', true, 1, '370', '583', true, 0, false, true, 0, 'T', false); $pdf->MultiCell(150, 10, $bill->payment, 0, 'C', true, 1, '370', '610', true, 0, false, true, 0, 'T', false); $pdf->MultiCell(150, 10, $bill->balance, 0, 'C', true, 1, '370', '660', 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', 460, 60, 80, 80, $style, 'N'); // $pdf->write2DBarcode('Qrcode', 'QRCODE,H', 80, 60, 0, 0, $style, 'N'); // --------------------------------------------------------- //Close and output PDF document $pdf->Output('Pacha-paints-Invoices.pdf', 'I'); exit(); @endphp