Advertisement
jamboljack

PDF NPWPD

Apr 29th, 2018
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.29 KB | None | 0 0
  1. public function print_card($employee_id)
  2.     {
  3.         $detail = $this->employee_m->select_by_id($employee_id)->row();
  4.         $pdf    = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  5.         $pdf->SetTitle('Cetak Kartu NPWPD');
  6.         $pdf->setPrintHeader(false);
  7.         $pdf->setPrintFooter(false);
  8.         $pdf->setFontSubsetting(true);
  9.         $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  10.         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  11.         $pdf->SetMargins(3.0, 25, 3.0); // left = 0.5 cm, top = 25 cm, right = 2.5cm
  12.         $pdf->SetFooterMargin(1.5); // the bottom margin has to be set with SetFooterMargin
  13.         $pdf->SetAutoPageBreak(true, 0);
  14.         // set some language-dependent strings (optional)
  15.         if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
  16.             require_once dirname(__FILE__) . '/lang/eng.php';
  17.             $pdf->setLanguageArray($l);
  18.         }
  19.         $pdf->SetFont('helvetica', '', 10, '', true);
  20.         $pagelayout = array(54, 85);
  21.         $pdf->AddPage('L', $pagelayout);
  22.         $style = array(
  23.             'position'     => '',
  24.             'align'        => 'L',
  25.             'stretch'      => false,
  26.             'fitwidth'     => true,
  27.             'cellfitalign' => '',
  28.             'border'       => false,
  29.             'hpadding'     => 'auto',
  30.             'vpadding'     => 'auto',
  31.             'fgcolor'      => array(0, 0, 0),
  32.             'bgcolor'      => false,
  33.             'text'         => false,
  34.             'font'         => 'helvetica',
  35.             'fontsize'     => 8,
  36.             'stretchtext'  => 3,
  37.         );
  38.  
  39.         $pdf->Cell(0, 0, $detail->employee_npwpd, 0, 1); // NPWPD
  40.         $pdf->Cell(0, 0, $detail->employee_name, 0, 1); // Nama
  41.         $pdf->Cell(0, 0, $detail->employee_address, 0, 1); // Alamat
  42.         $pdf->write1DBarcode($detail->employee_npwpd, 'C39', '', '', '', 12, 0.4, $style, 'N');
  43.  
  44.         $time        = time();
  45.         $filename    = 'Kartu_NPWPD_' . $detail->employee_npwpd . '_' . $time;
  46.         $pdfFilePath = FCPATH . "download/$filename.pdf";
  47.         $pdf->Output($pdfFilePath, 'F');
  48.         header("Content-type: application/pdf");
  49.         header("Content-Length:" . filesize($pdfFilePath));
  50.         readfile($pdfFilePath);
  51.         exit;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement