Advertisement
jamboljack

QRCode

Jun 24th, 2018
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.25 KB | None | 0 0
  1. public function preview($id)
  2.     {
  3.         $this->load->library('Pdf');
  4.         $data['detail'] = $this->siup_model->select_sk($id)->row();
  5.         $dataSK         = $this->db->get_where('c39_siup_datapemilik', array('id' => $id))->row();
  6.         if (count($dataSK) > 0) {
  7.             // Nama File PDF
  8.             $time     = time();
  9.             $filename = 'SK-SIUP-' . $id . '-' . $time;
  10.  
  11.             $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  12.             $pdf->SetTitle('Cetak SK SIUP');
  13.             $pdf->SetHeaderMargin(15);
  14.             $pdf->SetTopMargin(10);
  15.             $pdf->setFooterMargin(10);
  16.             $pdf->setPrintHeader(false);
  17.             $pdf->setPrintFooter(false);
  18.             $pdf->setFontSubsetting(true);
  19.             $pdf->SetAutoPageBreak(true);
  20.             $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  21.             if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
  22.                 require_once dirname(__FILE__) . '/lang/eng.php';
  23.                 $pdf->setLanguageArray($l);
  24.             }
  25.             $pagelayout = array(210, 330); // F4
  26.             $pdf->AddPage('P', $pagelayout);
  27.  
  28.             $style = array(
  29.                 'border'        => false,
  30.                 'vpadding'      => 'auto',
  31.                 'hpadding'      => 'auto',
  32.                 'fgcolor'       => array(0, 0, 0),
  33.                 'bgcolor'       => false, //array(255,255,255)
  34.                 'module_width'  => 1, // width of a single module in points
  35.                 'module_height' => 1, // height of a single module in points
  36.             );
  37.            
  38. // Data Barcode
  39.             $data['qrcode'] = $pdf->write2DBarcode('http://bpmppt.kuduskab.go.id/signature/' . $filename . '.pdf', 'QRCODE,H', 80, 210, 50, 50, $style, 'N');
  40. // View
  41.             $html = $this->load->view('kadin/siup/template_siup_v', $data, true, false, true, false, '');
  42.             $pdf->writeHTML($html);
  43.             $pdf->lastPage();
  44.  
  45.             $pdfFilePath = FCPATH . "signature/$filename.pdf";
  46.             $pdf->Output($pdfFilePath, 'F');
  47.             header("Content-type: application/pdf");
  48.             header("Content-Length:" . filesize($pdfFilePath));
  49.             readfile($pdfFilePath);
  50.             exit;
  51.         }
  52.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement